Expand my Community achievements bar.

Adobe analytics extension - clear variables on beacon fire

Avatar

Level 4

4/7/21

Description -
Add a feature to the extension to allow a checkbox to request that variables are cleared after the beacon fires.


Why is this feature important to you -

Nice generic feature instead of custom code to add to the extension


How would you like the feature to work -

When the option is checked - add the following after the extension is loaded

s.registerPostTrackCallback(function(){
  s.clearVars();
});

Current Behaviour

requires custom code

 

5 Comments

Avatar

Community Advisor

4/7/21

clearVars is already available as part of the Adobe Analytics extension without the need for custom code (although you do need to add an additional action)...

 

A_Wathen_0-1617813704464.png

 

Avatar

Level 4

4/7/21

I realize Clear Variables is there ... its a "code smell" that I need an addition action it every time I fire a beacon. When you have over 100 rules, that extra copy step is a bit tedious. (Which is why we added the listener so as to not worry about forgetting this action was done) 

Avatar

Community Advisor

4/7/21

That's really interesting that you've got over 100 rules that include the send beacon action and clearVars action.  We've set up Launch so that we've got just one rule that executes all the time to clearVars (we've used the ordering to ensure it always happens after the beacon has been sent), so we've only got one place we have to do this.  (we've also only got 2 rules for sending - one for s.t(), one for s.tl() )

 

I can understand how this might be a frustration if you're having to manage this in over 100 places!

 

Out of interest, what led you to take the approach you're taking rather than setting up with a single rule?

Avatar

Level 4

4/7/21

We originally tried that. Where we'd try the following pattern 

  • Set Variables custom for this event (typically 1 or 2 variables)
  • Call direct rule which would
    • set the rest of common evars and props (a dozen or more)
    • send the beacon
    • clear variables

Our problem was we were getting bugs where one or the other of the rules didn't have their variables set correctly. We also have many values set via javascript on various conditions. If felt like the javascript promises were firing out of order or some other oddity. Add to this - we had a 9 month support ticket open also related to DTM acting different in interacting with Analytics compared to launch and reproducible test case and were basically told ... Yeah - we don't know how to fix that since we don't think you should be relying on such a such feature. (Leaving vague since I don't want to dwell on it) But given that support ticket took forever to NOT be resolved with an answer - we were pressed for time to finish our DTM->Launch migration (since DTM goes full dark in one week for editing) - meaning we have ZERO time to wait on support as well as determine a workaround for the bug we initially reported.

 

So being tight for time - We simplified and did the following

  • In the Analytics extension config - Exposed a global setCommonVariables() method - It set all the common variables and conditionals in javascript.
  • Had each rule call that method in custom code in the SetVariables rule
  • So our actions typically look like
    • setVariables - where the variables set are spcific to that rule only
      • in setVariables - call the custom js code
    • Fire beacon
      • And let the custom listener clear variables

So far, this has been wildly successful and much easier to debug. 

 

Avatar

Community Advisor

4/7/21

Figures that you were working around an issue....

 

Particularly interested to hear that you've noticed some issue with the JavaScript promises... we've also noticed that it doesn't always seem to wait for one action to complete before executing the next (even though we got "run rule components in sequence" selected in the property), and we've also seen some oddities where the order of rule execution doesn't seem to be respected unless we put larger gaps between the order number (e.g. we can't go 1,2,3,4, we have to go 10, 20 ,30, 40 etc) - which is also weird.