MaximusDecimusMeridius
MaximusDecimusMeridius

Reputation: 135

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

I quickly ran in to the problem when trying to set up DTM that page load rules did not work when I have the s_code present on the page (and "s_code present" selected in DTM). I've been in touch with Adobes support for weeks now and they have not been able to figure it out (event rules work fine). I set up a test page with essentially just the s_code and DTM and nothing else

https://devpsstaging.phelpsagency.com/s_code_present-clean.html

If you check with a tool like Omnibug and DTM debugger you'll see that a pageload rule is fired ("page load test") through DTM but it is not sent with the actual image request. You can also view the debug info linked on the page itself: https://i.sstatic.net/6pwep.png

Can anyone help figure out why this is happening? The pageload rule is currently set to fire at top of page, but I get the same results regardless of what I set this to (top, bottom, dom, onload - page load rule fires but is not included in image request).

Does anyone know what's going on?

Upvotes: 0

Views: 2758

Answers (3)

Till Büttner
Till Büttner

Reputation: 46

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.

Upvotes: 1

Mark Stringham
Mark Stringham

Reputation: 421

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.

Upvotes: 0

CrayonViolent
CrayonViolent

Reputation: 32517

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.

Upvotes: 1

Related Questions