Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Adobe analytics implementation secret hacks

637 views

Published on

Undocumented (or almost undocumented) implementation features of Adobe Analytics

Published in: Technology
  • Slide 25, there's a typo in my code: CustomEvent takes an optional 2nd parametrer, a JSON object which can have the detail and bubbles properties. I simply forgot the curly brackets around the detail and bubbles properties for both events.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Es sieht so aus, dass manche Namics-Mitarbeiter aus der Schweiz und Deutschland diese Vorstellung besonders gut finden. Ich kann Deutsch fliessend sprechen, wenn sie Frage bzw Kommentare haben, bitte treten Sie im Kontakt mit mir!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • When you think of s.t() or s.track(), which are the same thing, they were not called s.tp() or s.trackPage(). Perhaps a long time ago s.t()/s.track() was the only function for all sorts of tracking, pageviews and interactions. Also the overrides syntax feels like something that's only working for backwards compatibility reasons, an ancient way of tagging.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Adobe analytics implementation secret hacks

  1. 1. Adobe Analytics implementation secret hacks Alban Gérôme MeasureCamp London XI 23 September 2017
  2. 2. The basics Pageviews tracking s.pageName="homepage"; s.channel="home"; s.prop1="home"; s.t(); Click tracking document.getElementByID("mybutton").addEventListener( "click", function(){ s.linkTrackVars="channel"; s.linkTrackEvents="None"; s.tl(true, "o", "my button was clicked"); } );
  3. 3. Page views tracking gotcha s.pageName="home"; s.channel="home"; s.prop1="home"; s.t(); s.pageName="products page 1"; s.channel="products"; s.t();
  4. 4. Once declared, a prop remains declared…
  5. 5. … unless you reset it explicitly or load a new page. This is also true for eVars, events etc
  6. 6. I am not talking about how eVars persist but about what your browser remembers
  7. 7. The overrides syntax Pageviews tracking s.pageName="homepage"; s.channel="home"; s.prop1="home"; s.t(); Overrides syntax s.t({ pageName:"homepage", channel:"home", prop1:"home" }); Click tracking document.getElementByID("mybutton").addEventListener( "click", function(){ s.linkTrackVars="prop2"; s.prop2="test"; s.linkTrackEvents="None"; s.tl(true, "o", "my button was clicked"); } ); Overrides syntax document.getElementByID("mybutton").addEventListener( "click", function(){ s.linkTrackVars="channel"; s.linkTrackEvents="None"; s.tl(true, "o", "my button was clicked",{prop2:"test"}); } );
  8. 8. Page views tracking revisited s.t({ pageName:"home", channel:"home", prop1:"home" }); s.t({ pageName:"products page 1", channel:"products" });
  9. 9. When you use the overrides syntax Adobe Analytics keeps your props private
  10. 10. Private and public data points Classic syntax = public s.pageName="homepage"; s.channel="home"; s.prop1="home"; s.t(); Your browser remembers the values of s.pageName, s.channel and s.prop1 Overrides syntax = private s.t({ pageName:"homepage", channel:"home", prop1:"home" }); Your browser sends the request and remembers nothing so you no longer need to clear your props, eVars, events etc when using virtual page views
  11. 11. Your props inside the s_code act as global constants if declared in the s_doPlugins function
  12. 12. s_code globals and constants • Declared inside the s_code but outside the s_doPlugins function Your props, eVars, events etc can be overridden by your page code • Declared inside the s_code, inside the s_doPlugins function Your props, eVars, events are protected and cannot be overwritten
  13. 13. You can combine props in your s_code file, in your page code using the classic syntax and props using overrides
  14. 14. The 3-layer onion s.t() using the overrides syntax for all props, eVars, events etc that are only relevant to the virtual page view you want to fire You can declare all props, eVars and events you share across all views displayed since the initial full page load using the classic syntax, they will ride on the same page view request as your overrides s.t() call All site-wide props, eVars and events should be declared in the s_code, outside the s_doPlugins function if you need to overwrite them on specific pages, inside if you want them protected and read-only
  15. 15. The onion challenge #1 prop1 was declared: • In the s_code with s.prop1="A" outside the s_doPlugins function • In the page code with s.prop1="B" • Inside the s.t() function with s.t({prop1:"C"}); Which value gets passed to the Adobe servers? Which value does the browser remember after the s.t() call fired?
  16. 16. The onion challenge #2 prop2 was declared: • In the s_code with s.prop2="A" inside the s_doPlugins function • In the page code with s.prop2="B" • Inside the s.t() function with s.t({prop2:"C"}); Which value gets passed to the Adobe servers? Which value does the browser remember after the s.t() call fired?
  17. 17. Don’t get me wrong, you do need to track interactions… you just don’t need s.tl
  18. 18. s.t() can fake s.tl() calls document.querySelector("button").addEventListener( "click", function(){ s.t({ lnk : true, linkTrackVars : "channel,prop1,prop2,prop3", linkTrackEvents : "None", linkName : "Button was clicked", linkType : "o", pageName : dataLayer.pageName, channel : dataLayer.channel, prop1 : dataLayer.prop1, prop2 : dataLayer.prop2, prop3 : dataLayer.prop3 }); } );
  19. 19. For the full list of overrides syntax properties just look inside what s.vl_g or s.va_g contains
  20. 20. Callbacks for page view tracking The s_doPlugins function executes every time you are about to track a page view with s.t() You can use that function to call a direct call rule declared in DTM for example in response to each page view or to fire a custom Javascript event It seems to work if you s.t() using the classic syntax but not the overrides syntax
  21. 21. Callbacks for page view tracking AppMeasurement 1.8.0 released on 19 Jan 2017 introduced these: • s.registerPreTrackCallback() – will fire a function before the s.t() call • s.registerPostTrackCallback() – same as above but after the s.t() call • Do not call these inside the s_doPlugins function • Do not call s.t() or s.tl() inside the callback functions or you will get infinite loops and rack up infinite server calls!
  22. 22. Callbacks for all tracking If you are on s_code H* and using the overrides syntax for the s.t() function, there’s still a way. It is risky and not supported by Adobe as you will need to modify code in the Do Not Modify part of the s_code It contains a function called s.mr() which stands for “make request”. It builds the entire URL for your request and sends it
  23. 23. Before im.src=rs; and/or after
  24. 24. Pre and post callbacks with s.mr() var preTrackCallBacks = []; var postTrackCallBacks = []; … //inside the s.mr() function preTrackCallBacks.map(function(pre){pre()}); im.src=rs; postTrackCallBacks.map(function(post){post()}); … //outside the s.mr() function preTrackCallBacks.push(function(){console.log("Measure")}); postTrackCallBacks.push(function(){console.log("Camp")});
  25. 25. Variant with custom JS events //inside the s.mr() function document.body.dispatchEvent(new CustomEvent( "preCallback", detail:{},//optional JSON of additional info bubbles:true//optional )); im.src=rs; document.body.dispatchEvent(new CustomEvent( "postCallback", detail:{},//optional JSON of additional info bubbles:true//optional ));
  26. 26. Many thanks! http://www.albangerome.com @albangerome
  27. 27. Further reading • Overrides syntax – very succinct documentation at Adobe https://marketing.adobe.com/resources/help/en_US/sc/implement/var_overrides.html • s.registerPreTrackCallback() and s.registerPostTrackCallback() – very succinct documentation at Adobe once again https://marketing.adobe.com/resources/help/en_US/sc/appmeasurement/release/c_release_notes_mjs.html • s_doPlugins function and DTM at Jan Exner’s excellent blog https://webanalyticsfordevelopers.com/2015/09/01/dtm-and-the-doplugins-callback/

×