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

Wrapping DTM Code in a Try/Catch

Avatar

Avatar
Validate 1
Level 1
CzechHarrison
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
CzechHarrison
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
CzechHarrison
Level 1

21-03-2016

Our developers have indicated in several tests that conflicts have occasionally caused issues with the loading of the DTM header library, so that when the footer runs, it generated a JavaScript error due to the _satellite.pageBottom() function not being found.

Are there any circumstances where wrapping the pageBottom function in a try/catch might cause issues?

Accepted Solutions (1)

Accepted Solutions (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

21-03-2016

Hi ,

We have not observed any circumstances where wrapping the pageBottom function in a try/catch block caused any issue. We have also tested the same on our test environment and the results were positive.Please find below try/catch block script being used.

To verify that our dynamic tag management header library is loading properly on our site, we used the command  _satellite.settings.notifications = true;  in  try block  and If the code was not properly installed, we will get the reference error: _satellite is not defined  and the same will caught by catch block  and  flag is set to 1 . 

Ultimately the  finally block runs and if flag is not 1 i.e. Header library is properly loaded, call the _satellite.pageBottom(); function.

<script> try{ _satellite.settings.notifications = true; } catch(err) { flag=1; console.log(err); } finally { if(flag!=1) { _satellite.pageBottom(); } else { alert("DTM Header Library not properly Loaded"); } } </script> </body> </html>

Please make sure to initialize the flag to 0 at the start of the head tag , like below :

<head> <script> var flag=0; </script> <script src="//assets.adobedtm.com/satelli4b6f12d-staging.js"></script>

 

Please let us know if you have any questions or queries.

Thanks & Regards

Parit Mittal

Answers (0)