Adobe Dynamic Tag Management (DTM) Page load rules not being captured

╄→гoц情女王★ 提交于 2019-12-04 22:43:13

Next to the Page code is already present option is a question mark (?) icon. If you click on it, you get a popup that tells you:

Prevents dynamic tag management from installing Adobe Analytics page code if the code is already present on your site. This feature allows you to use dynamic tag management to add to your existing implementation rather than starting from scratch. Be sure to properly set your tracker variable name when checking this box.

Admittedly, the popup description is misleading. It gives the impression that it simply doesn't build a new s object, but instead references an existing one. I have found that this is not the case at all. The Migrating to Dynamic Tag Management document entry is a little more clear about it, but I think they need to be more explicit about what this option really does..

Basically, that option is not meant to allow the code to run Adobe Analytics side-by-side with another existing implementation on the site. Nor does it just build off of what's already there.

It's meant to let you start the migration process and save your work and then after you remove your legacy on-page implementation, you uncheck that box to let DTM start outputting it. So, it won't actually build anything etc.. until you uncheck it. TBH, I don't really see the point of this option, seeing as how you can save without approving or publishing, but.. ::shrug:: whatever.

I'm actually more concerned that your Adobe Analytics code is working for the event based rules when you have this checked.. now THAT is the real bug to look into.

Configuring a Second Instance

In case you are in fact trying to implement two instances:

You may have noticed on that link above that Adobe claims you can nonetheless have a 2nd instance of Adobe Analytics (Omniture/SiteCatalyst) code on your page. The way it is supposed to work is you specify a different Object Name (something other than the default s namespace. Also you will not check the Adobe Analytics page code is already present option).

However, I should warn you about doing this. Basically, this only changes the top-level object namespace. Adobe Analytics code has a lot of underlying functions and variables that are in the global namespace that do not have any publicly exposed way to change them. In my testing of implementation through DTM, it does NOT change any of these underlying namespaces.

Thing is, I have observed out in the wild some "bleeding" over of variables and values between two top level namespaces, and I have seen one instance outright overwrite and/or break the other. This may be due to a number of factors like maybe differences in library versions or making an s.t or s.tl call under just the right circumstances; I really don't know. But I've seen it. Repeatedly, across multiple implementations with multiple clients. So, I don't trust multiple instances of Adobe Analytics on a page at all.

The question is a bit old. But i searched for an answer long time, then had a talk with Jan Exner and he found it. It is kind like dirty, but works :) You can use a script as plugin in s.doPlugins. The code looks like:

s.mergeDTMShadowData = function(toolID, overwrite) {
    // overwrite defaults to true
    if (typeof overwrite === 'undefined' || overwrite === null) {
        overwrite = true;
    }
    // check if DTM is present
    if (typeof _satellite !== 'undefined') {
        var analyticsTool = _satellite.tool[toolID];
        // is the analytics tool enabled?
        var enabled = true;
        if (analyticsTool.settings.initTool !== undefined && analyticsTool.settings.initTool === false) {
            enabled = false;
        }
        if (enabled === false) {
            // copy events
            var eventArray = analyticsTool.events;
            if (eventArray && eventArray.length > 0) {
                for (ev in eventArray) {
                    s.events = s.apl(s.events, eventArray[ev], ',', 1);
                }
            }
            // copy props & eVars
            var varArray = analyticsTool.varBindings;
            if (varArray) {
                for (variable in varArray) {
                    if (overwrite || typeof s[variable] === 'undefined' || s[variable] === null) {
                        s[variable] = varArray[variable];
                    }
                }
            }
        }
    } else {
        console.log('DTM not found, bailing out...');
    }
}

Turned into a plugin and using it directly in DTM, the complete solution looks like this:

s.mergeDTMShadowData=new Function("t","o",""
+"if(typeof o==='undefined'||o===null){o=true;}if(typeof _satellite!="
+"='undefined'){var a=_satellite.tool[t];var e=true;if(a.settings.ini"
+"tTool!==undefined&&a.settings.initTool===false){e=false;}if(e===fal"
+"se){var b=a.events;if(b&&b.length>0){for(c in b){s.events=s.apl(s.e"
+"vents,b[c],',',1);}}var d=a.varBindings;if(d){for(f in d){if(o||typ"
+"eof s[f]==='undefined'||s[f]===null){s[f]=d[f];}}}}}else{console.lo"
+"g('DTM not found, bailing out...');}");

s.doPlugins = (function() {
  return function() {
      s.mergeDTMShadowData("c7b417741f9f0d2435c6dd064ad9fc12",true);

      // now call the orignal
    var result = s_doPlugins.apply(this,arguments);
    return result;
  };
}());

Put that into the third-party/Javascript section of a Page Load Rule and you’re done. No changes are needed to the existing legacy code! None!

Need more information how it works, have a loot at the blog post: http://webanalyticsfordevelopers.com/2015/11/17/dtm-how-to-amend-an-existing-analytics-setup/

I just wanted to write it down here, so that anyone coming here later will find it.

To add to what Crayon has said, if you select the "page code present" option, the Adobe Analytics tool will not run. This option does however allow you to add to the existing page code through the JS / third party tag editor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!