Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

How to clear events using custom code?

Avatar

Level 6

s.linkTrackVars='events,eVar2,prop2';
s.linkTrackEvents=s.events='event2';
s.eVar2='radio button';
s.prop2='radio button';
s.tl(this,'o','radio button');
s.manageVars('clearVars',s.linkTrackVars,1);

 

Will this code clear evars, props and events after sending values?  If not what should I add to clear event values in custom code? Also what does 1 means in s.managevars?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

So, this code will indeed clear the specified eVars, props, and events after sending their values. The number 1 in s.manageVars() is an optional parameter that defines the scope of the operation. In this case, it means to clear only the variables included in s.linkTrackVars.

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

So, this code will indeed clear the specified eVars, props, and events after sending their values. The number 1 in s.manageVars() is an optional parameter that defines the scope of the operation. In this case, it means to clear only the variables included in s.linkTrackVars.

Avatar

Level 6

So If I want to clear counter event event2 what should I add? If I remove 1 will there be any impact?

Avatar

Community Advisor and Adobe Champion

I've never used the s.manageVars plugin... but I am trying to understand your use case here....

 

There is a "Clear Vars" command provided in Adobe Launch that you can use:

Jennifer_Dungan_0-1682430903008.png

 

However, if you are trying to target only specific items... like "events" in this case, you could just add:

s.linkTrackEvents=s.events='';

as your last line of code in this call....

 

I am guessing your implementation is something like this:

1. Page Loaded - Dimensions and Events are sent

2. There is a click that doesn't take you off the page that triggers event2

3. There is another click that doesn't take you off the page, or maybe it does, that has no events at all....

(And all of these are using some custom code, so you want to be able to make sure that the correct data is sent in each instance within your custom code)

 

 

You want to be sure that if the user does click "2" first (that sets event2), that event2 is not included on click "3".... 

 

You can also just force the events and linkTrackEvents in click 3 to be nothing on click 3

s.linkTrackEvents=s.events='';

 

This is often what I do... on my clicks, I enforce events to be set, or be empty (depending on my needs) before I trigger the s.tl() call... rather than clear it as part of the last click.

 

But then, I also do my clear vars differently than the "recommended"... I clear vars before my page view... so that all my correlation vars for clicks don't have to be re-set (they are all still available), and I can curate my linkTrackVars for each click adding new specific dimensions and events for my clicks. If I always ensure that s.events is set properly for the click event, I don't have to worry about contamination from my page or other clicks.

Avatar

Level 6

My req is very simple. There is link which on click will trigger event2. Again if  clicked will fire event2. So to use s.manageVars I need to install plugin global level? Is there any simple way of clearing variables using custom code before the same event takes place ?

Avatar

Community Advisor and Adobe Champion

If you have s.linkTrackEvents=s.events='event2'; in your code, and this same code is triggered, it will overwrite both s.linkTrackEvents and s.events... you don't need to "clear" anything.....

 

No matter how many times you click on the link that triggers this rule... you will send "event2" (and only send it once per click)