Expand my Community achievements bar.

DTM Page Load rule firing twice

Avatar

Level 3

Hi,

We have a page where we dynamically load the dtm footer code and whenever this page loads, all the page load rules (with condition as fires at the bottom of the page) get fired twice. I am not sure what's happening here. This is only happening with the page load rules which get fired at the bottom of the page and all the other rules get fired as expected.

Any pointers will be highly appreciated!

Thanks in advance.

12 Replies

Avatar

Level 10

Hi,

When you say your rule is being fired twice, are you seeing a message in the console with DTM Debug mode turned on indicating the rule fired twice or are you just seeing two identical beacons?

Thanks,
Jantzen

Avatar

Level 3

Hi Jantzen,

I am using DTM Switcher Debugger mode to see the number of rules getting fired on page load.

Avatar

Level 10

Can you include a screenshot of what you're seeing? Also, a URL of where this is occurring would allow me to do a bit more troubleshooting.

Avatar

Level 3

Hi Jantzen,

You can refer the attached screen shot. After I changed the rules condition to 'DOM Ready', I am able to fire all the rules only once. But, now the major issue is DTM is sending two beacons on this page load. I can see that after all the page load rules gets fired, DTM calls sendBeacon function to send data to Analytics server. However, later when DTM footer code gets included on the page, this also fires another beacon.

I am not sure what exactly is happening here. I tried changing doPlugins function in DTM, but this doesn't make any difference since this whole Analytics Tool setup works perfectly fine on the other pages. This problem exists on only one page. May be because this page has lots of contents to be loaded and takes time to include pageBottom function and this pageBottom function internally makes a call to the sendBeacon function.

1226773_pastedImage_1.png

Please advise.

Avatar

Level 10

You said " takes time to include pageBottom function" are you dynamically injecting the DTM Embed code into the page?

Also, do you have a URL where this is taking place? You shouldn't be getting two Analytics tracked a page view messages in the console. That message typically shows when the page load beacon has fired. If it's firing twice, I'd guess there is something going on with the implementation.

Avatar

Level 10

Thanks for sending the URL via private message. If possible, including it here publicly allows others to also try and troubleshoot.

I was able to look at the page and viewing the source code I wasn't able to find your DTM footer code "<script type="text/javascript">_satellite.pageBottom();</script>". Is the footer code being dynamically injected in? If so, could this be changed to be included statically like the header embed code?

Avatar

Employee

Hi jayak13010535​,

If the issue is still not resolved, I would suggest posting the URL along with the steps to replicate the issue so that we can try troubleshooting the issue at our end.

Avatar

Level 2

I've ran into the same issue before and here's what I was able to find.

My setup

<head><script src="satellite-code.js</head>

<body>

<script src="scripts-that-sets-digitalData-object-and-fire-an-event-when-ready.js" ></script>

<script type="text/javascript">

     jQuery(document).on('analytics-ready', (function() {

       _satellite.pageBottom();

    });

</script>

What I found is that this setup will always cause the DTM rules to fire twice. Because the logic in DTM code runs as follows:

Fire the rules if you see pageBottom on document load. If the rule wasn't run when the document is ready, DTM will fire the rule on DOM ready.  So it will fire once on DOM ready because pageBottom wasn't yet executed and the second time when my pageBottom function is called after DOM ready.

So pageBottom rule is really pageBottom or DOM ready, whichever comes first.

There is no real good way to tell DTM when the digitalData is ready and fire off the default rule then. :-(

Avatar

Level 1

Is there a solution for this to stop domready event..?

Avatar

Level 2

sunilrongali,

There is no way to stop the DOM ready event. The approach is to to disable the standard page load rule and use direct call rule to  track page views.

Avatar

Level 1

Thank u makbeta,

Can u please tell the steps involved in doing direct call rule instead of standard page load rule...

Does it mean, another js of adobe need to be included..?

Avatar

Level 2

sunilrongali,

This requires some DTM knowledge and could involve a lot of JS scripting.

In DTM you have  three rule types:

* Page Load Rules

* Direct Call Rules

* Event Call Rules

You would have to disable all page load rules from firing.

Create a new Direct Call rule.

Update your tracking code to call the newly created call rule after the data layer is created.

Extrapolating on the example above:

<script src="scripts-that-sets-digitalData-object-and-fire-an-event-when-ready.js" ></script>

<script type="text/javascript">

     jQuery(document).on('analytics-ready', (function() {

       _satellite.track('directCallRuleString');

    });

</script>

This is a high-level overview to help you get started. I cannot document all the steps involved as many depend on the specifics of analytics implementation in your site.

I hope this helps.