Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Launch success events counts will accumulate

Avatar

Level 3

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.

5 Replies

Avatar

Level 5

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:

  1. Explicitly unset the event in custom code. E.g. Using yuhuisg's code to unset all events.
  2. Set the event/fire beacon in custom code using variable overrides. This is personally my favorite technique to send data only relevant to click tracking that I don't want persisting after a click--event10 in your case.
  3. You could also make sure to set event10 in custom code to make sure you are resetting it as versus incrementing it. This can be dangerous if you are not careful to unset it as it could stay set even if you have other click tracking that wouldn't normally relate to event10.
  4. Create a decoupled, direct call rule to set variables so that it can be reused in multiple places (like pageviews and click tracking) without actually sending a beacon within that rule.

I'm sure there are plenty of other solutions available, but the first and second above are relatively quick and easy to setup.

Avatar

Level 3

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

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform-launch/adobe-analytics-ex...

Avatar

Level 5
Hi @tim_funk , part of the question was how to retain some of the variables after the beacon has fired. This would clear out those that are meant to persist.

Avatar

Community Advisor

You can use 

s.registerPostTrackCallback(function(){
  s.events = "";
});

to clear all of your s.events after each beacon call (hit) to AA.

Avatar

Level 5

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.