9. When you use the overrides syntax
Adobe Analytics keeps your props private
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. Your props inside the s_code act as
global constants if declared in the
s_doPlugins function
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. You can combine props in your s_code
file, in your page code using the classic
syntax and props using overrides
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. 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. 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. Don’t get me wrong, you do need to track
interactions… you just don’t need s.tl
19. For the full list of overrides syntax
properties just look inside what
s.vl_g or s.va_g contains
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. 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. 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
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. 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
));
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/