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

Need custom script to prevent Page load rule from firing if that same page is being refreshed or reloaded

Avatar

Avatar
Validate 10
Level 2
dariusd91806962
Level 2

Likes

5 likes

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
dariusd91806962
Level 2

Likes

5 likes

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
dariusd91806962
Level 2

06-10-2016

So I have a page load rule that fires for our career operations page and populates evar43 and event43.. I also put an event rule on a CTA button on the career operations page, the button is called "job openings" The event rule fires if the button is clicked and populates event44. However the problem is, that when the job opening button is clicked not only is the job listing page opened in new tab, but it also refreshes/reloads the career operations page cause the page load rule to fire again. Obviously this inflates the true count for Career operations page. So I need a custom script to add to the page load rule that basically says do not fire if already on the career operations page.  Any suggestions because I have not idea how I should do this. Oh by the way I am using DTM.

Thank you smiley

Darius Dempsey 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
AlexisCazes
MVP

Likes

186 likes

Total Posts

424 posts

Correct Reply

198 solutions
Top badges earned
Contributor
Shape 1
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Contributor
MVP
AlexisCazes
MVP

Likes

186 likes

Total Posts

424 posts

Correct Reply

198 solutions
Top badges earned
Contributor
Shape 1
Give Back 10
Give Back 5
Give Back 3
View profile
AlexisCazes
MVP

12-10-2016

ParitMittal wrote...

  1. Hi Darius ,
  2.  
  3. Please add the following code in Custom Code section of Adobe Analytics tab of your Page Load rule for "Career Operations Page". This code will suppress the beacon from firing if the career operations Page is refreshed or Reloaded.
 
  1.  
  2. if(window.performance)
  3.  
  4. {
  5.  
  6. if(performance.navigation.type == 1 )
  7. {
  8. alert("Reload");
  9.  
  10. s.abort = true;
  11. }
  12. };

Thanks & Regards

Parit Mittal

 


Hi Darius,

To add to Parit Answer.

Check this first: http://stackoverflow.com/questions/5004978/check-if-page-gets-reloaded-or-refreshed-in-javascript

So when the page is loaded for the first time the following:

window.performance.navigation

Return this:

PerformanceNavigation { type: 0, redirectCount: 0 }

Now if you reload the page you should see the following:

PerformanceNavigation { type: 1, redirectCount: 0 }

So Parit code is correct to check if page was reloaded but not to prevent the page load rule to fire. You need to put:

return false;

So the final code should look as follow:

var loadRule = true; if(window.performance) { //Reload of page if(performance.navigation.type  == 1 ){ loadRule = false; } } return loadRule;

I would also advis you to put this custom code in a Data Element to reuse it in all of your rules: example data element : loadRule

//Place in condition of any rule return _satellite.getVar("loadRule");

Best regards.

Alexis Cazes.

Lead Technical Support Engineer

Answers (1)

Answers (1)

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

12-10-2016

Hi Darius , Please add the following code in Custom Code section of Adobe Analytics tab of your Page Load rule for "Career Operations Page".  This code will suppress the beacon from firing if the career operations Page is refreshed or Reloaded. 
if(window.performance) { if(performance.navigation.type  == 1 ) { alert("Reload"); s.abort = true; } };

Thanks & Regards

Parit Mittal