5

I'm working on a wordpress site, and have been tasked with integrating with Adobe Analytics. The instructions are to include a script at the top of the page:

<script src="//assets.adobedtm.com/3202ba9b02b459ee20779cfcd8e79eaf266be170/satelliteLib-BlaBlaBla.js"></script>

and also to call a function before the closing </body> tag:

<script type="text/javascript">_satellite.pageBottom();</script>

However, due to the nature of wordpress, it's pretty hard to actually enforce that a script is the very last one before the </body> tag. I was thinking of firing the script on DOM ready

$(function(){
    satellite.pageBottom();
});

to ensure that this script gets run after the page has loaded and the other scripts have run. My question is: Is this an appropriate means of running Adobe analytics? I saw that this link here describes the Adobe lifestyle in part, but it doesn't look like it really answers my question: https://marketing.adobe.com/resources/help/en_US/dtm/load_order.html

Cheers

Jack
  • 472
  • 6
  • 13
  • 1
    The dtm footer code doesn't _have_ to be the very last item before the `

    ` tag, but you _cannot_ wrap it in DOM ready, window.load, setTimeout, mark it as async or deferred, etc. This will break a lot of DTM's functionality and [Adobe will not provide support for your implementation](https://marketing.adobe.com/resources/help/en_US/dtm/code.html)

    – CrayonViolent Feb 14 '17 at 15:26
  • Hi Crayon, if you put this as an answer, then I'll accept it – Jack Feb 22 '17 at 22:08
  • 1
    `pageBottom()` is used to execute scripts just before the DOM is ready. Execute it before the end of the document stream (the HTML parser is paused) allow executed scripts to insert HTML using `document.write()`. Use synchrous scripts is not adviced, but it's the only way to include Adobe DTM – mems Sep 27 '17 at 12:37

1 Answers1

0

For anyone else facing this issue, the answer is to not try and code your way through, but just to install the Adobe DTM plugin. Classic Wordpress - I should've checked if there was such a plugin at the start!

Jack
  • 472
  • 6
  • 13