We are implementing 3rd Party tags using DTM Event based rules. We are adding this as Non-sequential HTML or Non-sequential Javascript Third Party Tags.

But, the problem we face now is , we get some tags where it has <script> tags and within this script tags there is document.write() statement having a <script> tag to load a Javascript file.

eg :


var value = somevaluegenerated;

document.write('<script src="xyz.js?para1=one&para2=' + value + '"></script>);


How ever we found out that DTM does not support document.write() in this scenario.

Can you please let us know what is the option for adding such kind of 3rd Party tags?


Accepted Solutions (1)

Accepted Solutions (1)



Hi Neha,

DTM supports document.write(). The only thing which needs to be kept in mind is to change the syntax of <script> tag within the document.write function.  

 The reason why the above piece of your code is not working is that when we are embedding javascript in an HTML page the HTML parser when finds your first script tag will immediately try to find the closing tag. Since your closing script tag is in your document.write you'll find yourself in a pickle.

Hence the piece of code should be modified as :


var value = somevaluegenerated;

document.write('<script src="xyz.js?para1=one&para2=' + value + '"><\/script>');// This line is modified


We have also tested a piece of test code on our end and the code is perfectly working.

Thanks & Regards

Parit Mittal

Answers (0)