Including Adobe DTM asynchronous in AngularJS | Community
Skip to main content
New Participant
August 18, 2018
Solved

Including Adobe DTM asynchronous in AngularJS

  • August 18, 2018
  • 2 replies
  • 2832 views

We have a platform developed with AngularJS. The platform is the same for all our customers. We must include Adobe DTM only for a client.

I sometimes have external scripts that aren't loaded. Do you have a better way to do it?

here my code :

var adobedtm = '//assets.adobedtm.com/5249...abe2e5/satelliteLib-2d8560...eb5937-staging.js';

if( window._env.environment === 'production' ){
  adobedtm
= "//assets.adobedtm.com/5249...abe2e5/satelliteLib-2d8560...eb5937.js"
}

$
.getScript('//cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.8/postscribe.min.js', function (data, textStatus, jqxhr){
  postscribe
(document.body, '<script src="' + adobedtm + '" type="text/javascript"><script type="text/javascript">_satellite.setDebug(true);</script><script type="text/javascript">_satellite.pageBottom();</script>');
});

https://i.stack.imgur.com/NbNTI.png

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Stewart_Schilling

Have you considered using Launch instead of DTM?

DTM is full of document.write calls which is OK if you're using DTM in a supported way (i.e. Header embed synchronously loaded in the HEAD, and pageBottom() synchronously called just before the closing BODY tag).   There are certain expectations that DTM has regarding when it is being invoked within the lifecycle of a page being rendered.  Your implementation does not support DTM's expectations.

Launch, however, supports async embed and does not require the pageBottom call.

If you absolutely can't move to Launch, I'd suggest looking at the contents of each of these scripts and seeing why they cannot be loaded after DOM ready.  If they are "sequential JS" try changing to "non-sequential JS". 

2 replies

Stewart_Schilling
Stewart_SchillingAccepted solution
New Participant
August 21, 2018

Have you considered using Launch instead of DTM?

DTM is full of document.write calls which is OK if you're using DTM in a supported way (i.e. Header embed synchronously loaded in the HEAD, and pageBottom() synchronously called just before the closing BODY tag).   There are certain expectations that DTM has regarding when it is being invoked within the lifecycle of a page being rendered.  Your implementation does not support DTM's expectations.

Launch, however, supports async embed and does not require the pageBottom call.

If you absolutely can't move to Launch, I'd suggest looking at the contents of each of these scripts and seeing why they cannot be loaded after DOM ready.  If they are "sequential JS" try changing to "non-sequential JS". 

New Participant
August 18, 2018

And I can’t include for all our clients. I forgot to put the screenshot.

NbNTI.png