Reputation: 1
I am migrating from static implementation to Adobe DTM. There are certain page level codes like for example, s.prop14=Name of Article. But now when I have given the reference of DTM, the page level codes are not firing and I am getting the error in console that object "s" is not defined.
What's the solution for this?
Thanks!
Upvotes: 0
Views: 556
Reputation: 32517
By default, DTM does not put the s
object (or whatever other namespace you specify in the config) in the global (window
) scope, and DTM doesn't natively allow you to. You will have to update your tool config to do it yourself, and incidentally, this also means you will have to maintain the core library yourself instead of making use of the "Managed by Adobe" feature, to get around DTM trying to do it automatically.
In the Library Management > Code Configuration section, choose Custom and check the Set report suites using custom code below. Then you will need to either host the library either "In DTM" (click on "Open Editor" and copy/paste it into there) or "At URL" (host the file yourself). At the top (whether in editor or in file), you will need to instantiate the object under the window namespace. Example for AppMeasurement:
window.s = new AppMeasurement();
Alternatively, you can leave your setup as-is, and change the on-page syntax a bit, and then add some code to DTM to look for it. For example, above your on-page custom code, just do
var s = {};
s.prop1 = 'foobar';
//etc..
And then in DTM, in the same code editor (or in a rule.. lots of places within DTM you can do this), you can do for example:
for (var v in window.s) {
s[v] = window.s[v];
}
Upvotes: 4