Reputation: 1
We are integrating google recaptcha using https://www.google.com/recaptcha/api.js. This script has var s in it. we also have a global var s in one of our sitecatalyst.js file.
We faced an issue where after loading google recaptcha, var s of sitecatalyst.js was overwritten by the var s of api.js.
We get undefined method when invoking a method of var s of sitecatalyst.
How can we resolve this conflict?
Upvotes: 0
Views: 227
Reputation: 32537
Firstly a note that whatever s
namespace conflict you are having with Adobe Analytics (AA), is not from the google recaptcha api.js script. The s
namespace used in there is enclosed and declared within an anonymous function, so its scope is only within that anonymous function. So, this is not what is overwriting your AA s
object; look elsewhere.
But in general, as far as avoiding this from happening in the first place.. yes, Adobe Analytics does by default use a global s
(window.s
) namespace.
Depending on your library version, you should see in your code something like this:
var s = s_gi('some value');
or this:
var s = new AppMeasurement()
;
This is where you can change the main AA object namespace.
You will also need to update references to the s
namespace elsewhere in your code. Firstly, if you are using any AA plugins (e.g. s.getQueryParam
, s.getValOnce
, etc.) you will need to update them to reference your new namespace. Note: you just need to update the namespace of the declared plugin, not the code within. Most of the plugins, within them, have at the beginning of them something like var s=this;
do not change this. That is scoped within the plugin itself, similar to the google api.js script I mentioned above.
You will need to ensure it is updated everywhere else you set AA variables, e.g. on-page custom variables, the s.t()
call for page views, etc.
Since you are talking about the library in js files, it sounds like you have not yet migrated to Adobe Dynamic Tag Manager (DTM) or some other tag manager. If that is the case, and you want to change the namespace (you should, to avoid namespace conflicts), then I would recommend using this as an opportunity to migrate to a tag manager.
Also, if you are going to do this and are not on the latest AppMeasurement library (especially if you are using legacy H code, which is highly likely if you are still hosting AA lib files yourself), I recommend using this as an opportunity to update your code library.
Upvotes: 1