DTM Examples- Appending a Third-Party Tag Non-Sequentially

Certain behaviors common to Third Party Tag scripts will not work as asyncronous JavaScript or HTML, or after the DOM has finished loading.

For example, a Doubleclick Floodlight tag might look like this:

<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="//0.fls.doubleclick.net/activityi;src=0;type=fake_tag;cat=fake_tag;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');

<iframe src="//0.fls.doubleclick.net/activityi;src=0;type=fake_tag;cat=fake_tag;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe>
<!-- End of DoubleClick Floodlight Tag: Please do not remove -->

Because this uses "document.write" to create an iframe, this can cause an error- you can't write to a document after it has completed.

You can use document.body.appendChild to add something to the page after it has finished loading.

var axel = Math.random() + "";
var a = axel * 10000000000000;

var dcIMG = document.createElement('iframe');

dcIMG.setAttribute('src', "https://0.fls.doubleclick.net/activityi;src=0;type=fake_tag;cat=fake_tag;ord="+a);