variableOverrides JavaScript - alcazes/Adobe-Analytics-from-A-To-Z GitHub Wiki

variableOverrides in Adobe Analytics JavaScript tracking

For Adobe Analytics it is possible to send a one off variable override. It is useful if you do not want to modify you default tracking that would apply in 99% of time.

You can apply variable overrides for both pageView tracking (s.t()) and link tracking (s.tl()).

Order of excution

Please be aware that variableOverrides will overwrite any code on the page but it will ran before doPlugins function.

This means that it is highly possible that code in doPlugins might overwrite data set with variableOverrides if you are not careful.

It is advised to set the following in doPlugins to make sure any previous data set is not overwritten:

//If no data in the variable

if(!s.variable){

//then do something

}

s.t() and variableOverrides

You can use a code similar to the following to use variableOverrides in a JavaScript implementation for s.t().

Without contextData

variableOverrides = {};
variableOverrides.pageName = "Variable Override pageName";
s.t(variableOverrides);

Example of image request

"AppMeasurement Debug: http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s75166509135023?AQB=1&ndh=1&pf=1&t=28%2F2%2F2016%2010%3A3%3A0%201%20-60&fid=16FF6043AC082526-026CADF37486C371&ce=UTF-8&ns=cardgagecorp&pageName=Variable%20Override%20pageName&g=http%3A%2F%2Flocalhost%2FtrainingVid%2FHTML5%2FHTML5-video-tracking.html&c50=test&s=1920x1080&c=24&j=1.8.5&v=N&k=Y&bw=1071&bh=893&AQE=1
    http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s75166509135023?AQB=1
    ndh=1
    pf=1
    t=28/2/2016 10:3:0 1 -60
    fid=16FF6043AC082526-026CADF37486C371
    ce=UTF-8
    ns=cardgagecorp
    pageName=Variable Override pageName
    g=http://localhost/trainingVid/HTML5/HTML5-video-tracking.html
    c50=test
    s=1920x1080
    c=24
    j=1.8.5
    v=N
    k=Y
    bw=1071
    bh=893
    AQE=1"

With contextData

variableOverrides = {
    contextData: {}
};
variableOverrides.pageName = "Variable Override pageName";
variableOverrides.contextData["ContextDataOverride"] ="Variable Override Context data";
s.t(variableOverrides);

Example of image request

"AppMeasurement Debug: http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s7761529885171?AQB=1&ndh=1&pf=1&t=28%2F2%2F2016%2010%3A9%3A49%201%20-60&fid=16FF6043AC082526-026CADF37486C371&ce=UTF-8&ns=cardgagecorp&pageName=Variable%20Override%20pageName&g=http%3A%2F%2Flocalhost%2FtrainingVid%2FHTML5%2FHTML5-video-tracking.html&c.&ContextDataOverride=Variable%20Override%20data&.c&c50=test&s=1920x1080&c=24&j=1.8.5&v=N&k=Y&bw=1071&bh=893&AQE=1
    http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s7761529885171?AQB=1
    ndh=1
    pf=1
    t=28/2/2016 10:9:49 1 -60
    fid=16FF6043AC082526-026CADF37486C371
    ce=UTF-8
    ns=cardgagecorp
    pageName=Variable Override pageName
    g=http://localhost/trainingVid/HTML5/HTML5-video-tracking.html
    c.
    ContextDataOverride=Variable Override data
    .c
    c50=test
    s=1920x1080
    c=24
    j=1.8.5
    v=N
    k=Y
    bw=1071
    bh=893
    AQE=1"

s.tl() and variableOverrides

You can use a code similar to the following to use variableOverrides in a JavaScript implementation for s.tl().

Without contextData

variableOverrides = {};
variableOverrides.pageName = "Varaible Override pageName LINK";
s.tl(this,"o","Custom link",variableOverrides);

Example of image request

"AppMeasurement Debug: http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s79252256174509?AQB=1&ndh=1&pf=1&t=28%2F2%2F2016%2010%3A12%3A8%201%20-60&fid=16FF6043AC082526-026CADF37486C371&ce=UTF-8&ns=cardgagecorp&pageName=Varaible%20Override%20pageName%20LINK&g=http%3A%2F%2Flocalhost%2FtrainingVid%2FHTML5%2FHTML5-video-tracking.html&pe=lnk_o&pev2=Custom%20link&AQE=1
    http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s79252256174509?AQB=1
    ndh=1
    pf=1
    t=28/2/2016 10:12:8 1 -60
    fid=16FF6043AC082526-026CADF37486C371
    ce=UTF-8
    ns=cardgagecorp
    pageName=Varaible Override pageName LINK
    g=http://localhost/trainingVid/HTML5/HTML5-video-tracking.html
    pe=lnk_o
    pev2=Custom link
    AQE=1"

With contextData

variableOverrides = {
  contextData: {}
};
variableOverrides.linkTrackVars = "contextData.ContextDataOverride" ;
variableOverrides.pageName = "Varaible Override pageName LINK";
variableOverrides.contextData["ContextDataOverride"] ="Varialbe Override data Link";
s.tl(this,"o","Custom link",variableOverrides);

Example of image request

"AppMeasurement Debug: http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s7314040085142?AQB=1&ndh=1&pf=1&t=28%2F2%2F2016%2010%3A13%3A23%201%20-60&fid=16FF6043AC082526-026CADF37486C371&ce=UTF-8&ns=cardgagecorp&pageName=Varaible%20Override%20pageName%20LINK&g=http%3A%2F%2Flocalhost%2FtrainingVid%2FHTML5%2FHTML5-video-tracking.html&c.&ContextDataOverride=Varialbe%20Override%20data%20Link&.c&pe=lnk_o&pev2=Custom%20link&AQE=1
    http://cardgagecorp.112.2o7.net/b/ss/edirocks/1/JS-1.4.4/s7314040085142?AQB=1
    ndh=1
    pf=1
    t=28/2/2016 10:13:23 1 -60
    fid=16FF6043AC082526-026CADF37486C371
    ce=UTF-8
    ns=cardgagecorp
    pageName=Varaible Override pageName LINK
    g=http://localhost/trainingVid/HTML5/HTML5-video-tracking.html
    c.
    ContextDataOverride=Varialbe Override data Link
    .c
    pe=lnk_o
    pev2=Custom link
    AQE=1"