[AAE] Have Adobe Analytics Global Variables fire on all AA rules | Community
Skip to main content
Jennifer_Kunz
New Participant
August 21, 2018
Approved

[AAE] Have Adobe Analytics Global Variables fire on all AA rules

  • August 21, 2018
  • 23 replies
  • 36737 views

The variables set in the Analytics extension's Global Variables seem to not fire on all rules/rule types (see Global Variables - Direct Call Rule ). This is similar to how it was in DTM.

It would be great if we had some control over this (maybe give me the ability to say "fire for all beacons" or "fire for all s.t beacons" or "fire immediately before any beacon, but after other rules" or something), or by default they DID fire anywhere the Analytics Extension was in a rule. Otherwise, folks still have to resort to using doPlugins, or setting up a rule for global variables that somehow fires on all other AA rules/beacons.

23 replies

Jennifer_Kunz
New Participant
August 3, 2020

I only just got around to testing this and for me, the global variables still not fire on on an s.tl beacon (if I had set clearvars on the page view beacon- I suspect this might be the difference?). 

New Participant
December 1, 2019

Correct, I don't use s.clearVars() because it's so destructive.

 

Instead, I use s.registerPostTrackCallback() like so:

 

s.registerPostTrackCallback(function(requestUrl, s) {

  _satellite.logger.warn('s.registerPostTrackCallback() called');

 

  // unset variables and events that are not needed after sending a beacon

  // BUT LEAVE BEHIND variables that should remain, e.g. those that are set in the Adobe Analytics extension itself

 

  var doNotUnsetVariables = [

    // list of variables to keep between hits, including pageName, hierN, server, channel, etc.

  ];

  var doNotUnsetVariablesRegExp = new RegExp('^(' + doNotUnsetVariables.join('|') + ')$');

 

  // find and erase all unneeded variables: eVar's, hier's, prop's, products

  var setVariables = Object.keys(s).filter(function (k) {

    return /^((eVar|hier|prop)[0-9]+|products)$/.test(k);

  });

  var unsetVariables = setVariables.filter(function (k) {

    return !doNotUnsetVariablesRegExp.test(k);

  });

  unsetVariables.forEach(function (v) {

    s[v] = '';

  });

 

  // erase all success events

  s.events = '';

}, s);

 

I'm not sure if there's a better way to clear variables selectively, but this works for me.

 

However, due to Launch's asynchronous firing, if I fire two s.tl()'s together, there's a very high chance that the subsequent s.tl() will send variables that were in the first s.tl(), even though I don't want them to be.

Urs_Boller
New Participant
November 27, 2019

and what happens if you have two (or more) s.tl() on the same page (without page reload an clear vars)? will it keep all the variables/events or always start "from scratch"?

Urs_Boller
New Participant
November 27, 2019

the question is if you need a "clearVariables" at the end of all rules? otherwise I think it will keep the old variables/events and messing up tracking (eg. you set a specific event on s.t() and it will appear on the subsequent s.tl() call...

Jennifer_Kunz
New Participant
November 27, 2019

Intriguing, thanks for letting me know! I'll have to test and see if this has, in fact, been resolved!

New Participant
November 27, 2019

FYI I've never encountered this problem since using Launch in October 2019.

My setup:

  • Adobe Analytics extension: include all global variables to be set with all AA hits.
  • Rules: include variables that should be set in those rules.

Result:

All of my AA hits include my global variables, including s.tl() hits.

New Participant
October 30, 2019

I do have the same issues on custom event calls. Solved it by a helper function, which sets all global variables on events. I once define the global variables in this function, and then call it in the AA Set Variables component (on every rule) in custom code and works perfectly. But yes, this should be handled without custom code.

Jennifer_Kunz
New Participant
April 29, 2019

even if I move all s.tl beacons to rules, this is still an issue.... my global variables don't fire on my s.tl rule-based beacons either.

Jennifer_Kunz
New Participant
April 29, 2019

I can see this working and is a good solution in the current set up, but I still definitely would like a way to do it without having to make sure my "global" rule gets triggered for ALL rules/beacons.

New Participant
April 28, 2019

I've achieved this by stacking rules, and pushing all analytics track events down through a single direct call which has a number of different rules listening, in a specific order. Some rules are conditional, some aren't - so this way, I can control certain variables that apply to everything, and certain variables that are conditional. The last rule fires the beacon. Maybe not ideal, but it works well for us.

This also allows us to reference analytics variables in a specific order: for example, we set hierarchy variables based on s.pagename (with some modification), if I do this in the extension I cannot control the order in which it is evaluated and therefore I end up with incorrect variable settings, but by doing this in stacked rules I can easily control the order of evaluation and ensure the result is correct. Even if we had the ability to choose when the global variables are evaluated (s.t vs s.tl / etc), it would not address my requirement to control the order of evaluation as that would be unique to my implementation and each property.