Adobe DTM: Using doPlugins to capture every hit for pathing report

If you want to see user’s full path including custom hits you have to save data to Adobe’s prop variable (pathing enabled!) on every hit you make. If you are starting to tag new site you could just choose one prop and hardcode it to the site every time hit is done to Adobe Analytics or by using dynamic tag management you could add that prop to every hit/rule. Yes, you have to always remember to do this and it is a bit work, but this way you can also choose how you would like to name these prop values and that way you get your ideal pathing report.

If we are talking about already a tagged site and you are always sending some kind of eVar with custom hits. Then you could make a small javascript to copy value from pageName and eVarX to this prop variable or you could use processing rule to do this also.

However, someone asked how you could do this easily in Adobe’s dynamic tag management when you have already many custom hits/rules made and maybe without eVar variables that it would be too much work to add prop variable to every rule you have made on DTM. Since I have started to realize the power of tag managment and hopefully going to use TMS much more in the future I decided to figure this out. Of course the first question was could this be accomplished with just one rule or simple setting in DTM, but I didn’t find any information how you could do that and after asking from more experienced DTM users it sounded like it’s not possible with one magic touch. Please, comment if you now the trick.

Anyway, I was sure that we could accomplish this by using javascript, but I faced few problems that I didn’t have instant answer.

1) Adobe Analytics settings in DTM, and I noticed Adobe is hosting the script/library for me and I want it to be so. How could I now add javascript to my Adobe script before the hit is made? Of course I can make all kinds of javascript hacks to data elements and rules, but I would need to hack the script just before hit is sent to Adobe’s server.

Yes, I had noticed “customize page code” in DTM’s Adobe Analytics settings, but for some reason I didn’t read the small text and thought that part was got something to do with pageviews only etc. But no, this is exactly the right place to do some javascript hacks. Bueno!

customize_page_code_dtm

Ok, so I can add javascript in here, but how could I add javascript hack also for custom hits which doesn’t load pageview. I did some google searching and I should have know the answer without googling. Yes, the good old doPlugins. If I add something inside doPlugins it is then done just before the hit is sent to Adobe’s server. Voila! We are getting very close to achieve what we want to do.

2) Problem number two, how can I know using javascript when tagged custom link is populated and starting it’s journey to Adobe’s server? Well, I knew that pageview is sent by s.t(); function and s.tl(); is used for custom hits. But I can’t make a hack like this “if s.tl(); {do something}”. Is there any other differences between pageview and custom hits? Lucky we, there is. Custom hits always include additional information, e.g. s.tl(true,’o’, ‘custom_name’); Read more in here https://marketing.adobe.com/resources/help/en_US/sc/implement/util_linkhandler.html

Oh yes, e.g. link type exists when custom hits is about to be sent. So we could make javascript “if linktype is there, then add propX”. You can code the javascript in many ways and especially change the format what kind of information you want to add to prop variable, here is my latest version of the code:

s.usePlugins=”true”;
function s_doPlugins(s)
{
if (s.linkType) {
// if linkType is there then we know custom hit is done
s.prop24=”Link: ” + s.linkType + ” + ” + s.linkName;
// How we want to see custom hit in pathing report, you can modify and maybe add some error handling if linkName is missing etc.
} else {
s.prop24=”Pageview: ” + s.pageName;
}

if (s.linkTrackVars) {
// custom hit containing eVar/prop variables always need this variable to be populated too
s.linkTrackVars +=”,prop24″;
// important little check, so we don’t delete other variables if there are some already included, note the + sign and , sign
} else {
s.linkTrackVars=”prop24″;
// if no other eVars and props are included in the hit, then we can just add our little path prop
}
}
s.doPlugins = s_doPlugins;

And this way we can capture every hit that is sent to Adobe’s server and we always send value for our pathing enabled prop variable. I added link type and link name, and this way I can get unique value for my prop for custom hits. You can modify the code in many ways, you could e.g. just save value for prop only if the link type is “other” and forget download and exit links. That would be possible with this: if (s.linkType == “o”)

What did we just do: with simple javascript hack we saved many hours of work, and now it is not necessary to add prop variable to every rule you have made in DTM. For me the biggest lesson was that you can customize the script even when Adobe is hosting the library and with doPlugins you can hack all hits just before data is sent to Adobe’s servers, and the above script/hack was just one example and you should remember that everything is possible… 🙂

You should probably prefer DTM’s basic settings and data elements to make all kinds of hacks to save information, but if you prefer old school way then in here (customize page code) you can do pretty much anything you want to, even though, Adobe is hosting the default script/library for you, oh yeah!

This was my first post about Adobe dynamic tag management, so please be gentle if you noticed mistakes or know better way to do this kind of hack. Again, comments are appreciated if you have anything related to share. Thanks.

Ps. Here are some resources related to my blog post that I found when trying to find answers to my problems:

http://webanalyticsfordevelopers.com/2015/09/01/dtm-and-the-doplugins-callback/

https://marketing.adobe.com/resources/help/en_US/sc/implement/index.html?f=util_linkhandler

http://www.searchdiscovery.com/blog/adobe-dtm-update-let-adobe-manage-measurement-library/

http://stackoverflow.com/questions/22205323/is-there-a-method-within-omnitures-s-code-to-see-whether-a-pageview-has-fired

http://blogs.adobe.com/digitalmarketing/analytics/custom-link-tracking-capturing-user-actions/

http://jimalytics.com/tag-management/dynamic-tag-manager-dtm-cheat-sheet/

http://www.digitaldatatactics.com/examples/troubleshooting.html

About Antti

Antti

Digital Analytics Manager specialized in Adobe Analytics, Online personalization, SEO, CRO...

Leave a Reply

Your email address will not be published. Required fields are marked *