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
BedrockMission!

Learn More

View all

Sign in to view all badges

When to use clearVars

Avatar

Avatar
Validate 1
Level 2
Berus
Level 2

Likes

4 likes

Total Posts

20 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Shape 1
Give Back
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Berus
Level 2

Likes

4 likes

Total Posts

20 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Shape 1
Give Back
Boost 3
Boost 1
View profile
Berus
Level 2

05-10-2020

Hi all,

 

I feel like this is a tricky question, should s.clearVars(); be used before or after? Couple of use cases I have encountered, 

 

#1 In Launch, 

Clear Variables > Set Variables > Send Beacon

 

#2 Using AMO.js 

Track events and eVars > fire s.tl() > call s.clearVars()

 

#3 CMS Application 

s.linkTrackVars="events,eVar100";
s.linkTrackEvents="events,event200";
s.events="event200";
s.eVar100="some variable;
s.tl(this,"o",null);

In this case I was questioning when to fire s.clearVars()? Because i'm running into an issue where the event200 is getting picked by AMO.js and the same event is getting fired twice on separate occasions. 

 

Is there a general rule which says fire s.clearVars() before tracking or after s.tl()? or is it custom?, based on use cases, like, it can be used either before or after? 

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Affirm 25
Employee
Khurshid_Alam
Employee

Likes

56 likes

Total Posts

189 posts

Correct Reply

41 solutions
Top badges earned
Affirm 25
Boost 50
Affirm 10
Boost 25
Affirm 5
View profile

Avatar
Affirm 25
Employee
Khurshid_Alam
Employee

Likes

56 likes

Total Posts

189 posts

Correct Reply

41 solutions
Top badges earned
Affirm 25
Boost 50
Affirm 10
Boost 25
Affirm 5
View profile
Khurshid_Alam
Employee

06-10-2020

It specially help in SPAs where you want to clean all the variables before sending a new server call. 

Avatar

Avatar
Publish 1
MVP
yuhuisg
MVP

Likes

195 likes

Total Posts

595 posts

Correct Reply

117 solutions
Top badges earned
Publish 1
Affirm 100
Springboard
Bedrock
Validate 1
View profile

Avatar
Publish 1
MVP
yuhuisg
MVP

Likes

195 likes

Total Posts

595 posts

Correct Reply

117 solutions
Top badges earned
Publish 1
Affirm 100
Springboard
Bedrock
Validate 1
View profile
yuhuisg
MVP

06-10-2020

You determine when you want to use s.clearVars(). There's no hard-and-fast rule. It's simply a convenient way to "wipe the slate clean" before the next tracking call.