If I have many events/or 1 click event click for more than 1 times on the same page,the event counts will be accumulate
Such as if I click a button (event10) 3 times,I want it to be the first time: event10=1 the second time: event 10=1 the third time event10=1, totally 3 times.
However it showed as the first time: event10=1 the second time: event 10=2 the third time event10=3, totally 6 events were recorded/send.
A similar situation also happened in different button clicks on one page.
If I clear variables after sending beacon, the other useful eVars and Props will be all clear (I have more than 50 eVars/props so It will be a huge work for me to reset the other variable after clear variable), so how can I just celar the variables of the event10 or let it not accumulate.
Solved! Go to Solution.
Views
Replies
Total Likes
A note with this method:
As a pre-req, you will need to make sure that the s object is defined globally in your Analytics extension.
Then, this code must be placed in an action before sending the beacon or in a rule must fire before the one used to track your event, event10. If the intention is to use this after all beacons, then it should go in a separate rule that fires before any other rules that send a beacon. If placed in custom code before using the AA extension, you could run into a race condition where the s object has not yet been defined. To avoid that senario, you could reference the AA library within the rule. As an example, you could use an AA clear variables (which would run before any variables are even set, but ensure the library is loaded and the s object is defined) and then include this custom code.
Hi @DebbyNPL ,
It does sound like clear vars is normally the right way to go, but you have several options if you want the remaining variables to persist:
I'm sure there are plenty of other solutions available, but the first and second above are relatively quick and easy to setup.
If you remain on the page to allow subsequent events trigger, you need to clearVars after each beacon send otherwise each event will have all the variables included from before (or at least the ones not overridden)
So adding the clear variables rule after the beacon fire is the way to go. If you have a lot of rules (and depending on your setup) - this can be annoying (it was for me).
Luckily - There is a nuclear approach to fix this. Adobe analytics allows for a hook to fire after the beacon is sent. So you can create a hook (code follows next) to clear vars after the beacon is sent. Then this is done universally on the property and you don't need to worry about it anymore. Place this code either as a piece of custom code in the analytics extension, or as a new rule that fires ONCE before any beacons are sent.
s.registerPostTrackCallback(function(){
s.clearVars();
});
I also submitted a RFE so we can avoid pasting in code since (I believe) this is a common use case
You can use
s.registerPostTrackCallback(function(){
s.events = "";
});
to clear all of your s.events after each beacon call (hit) to AA.
A note with this method:
As a pre-req, you will need to make sure that the s object is defined globally in your Analytics extension.
Then, this code must be placed in an action before sending the beacon or in a rule must fire before the one used to track your event, event10. If the intention is to use this after all beacons, then it should go in a separate rule that fires before any other rules that send a beacon. If placed in custom code before using the AA extension, you could run into a race condition where the s object has not yet been defined. To avoid that senario, you could reference the AA library within the rule. As an example, you could use an AA clear variables (which would run before any variables are even set, but ensure the library is loaded and the s object is defined) and then include this custom code.
Views
Like
Replies
Views
Likes
Replies