Expand my Community achievements bar.

Failed to execute 'write' on 'Document' - Error while trying to load DTM

Avatar

Former Community Member

I am trying to add DTM to our webpages.
Since we cannot directly add the script tags on our pages, I am adding it via a script.

var dtm = window.parent.document.createElement('script'); dtm.type="text/javascript"; dtm.id = '_adobe_dtm_script_tag'; dtm.src='//assets.adobedtm.com/146bfceac85235cee2e586a6ad3c7dfb986e2808/satelliteLib-9e5c727e63dd5f355d211e97cb053ed84753e95b.js'; var d = window.parent.document.getElementsByTagName('head')[0]; d.appendChild(dtm); var dtmf = window.parent.document.createElement('script'); dtmf.type="text/javascript"; dtmf.id = '_adobe_dtm_script_footer_tag'; dtmf.text='_satellite.pageBottom();'; var bd = window.parent.document.getElementsByTagName('body')[0]; bd.appendChild(dtmf);

However, on executing this script, we can see that ADTM as a tag is added to the page, but all the pixels are not being loaded.
The console gives an error message as follows:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

Unable to find a clear solution for the same.. Please help

1 Reply

Avatar

Level 7

The only supported way to implemented DTM is by hard coding it to the page, any other way than this will mean Adobe will be unable to support your implementation.

Becasue of the way you are implementing DTM any functions which rely on non ASYNC loading will be rendered unusable.