Rich-text Reply

Should we split the script tags in Optimizely code? Using document.write via tag manager Tealium

4WD 03-05-15

Should we split the script tags in Optimizely code? Using document.write via tag manager Tealium

[ Edited ]

We are implementing Optimizely across a site with Tealium (a tag manager), following the synchronous loading guide.

 

A development agency want to implement the tracking code in the following way:

 

document.write('<scr' + 'ipt src="//cdn.optimizely.com/js/123456789.js"></scr' + 'ipt>');

 

(Note how the script tags are split.)

 

Can you see any issues for Optimizely experiments when doing it this way? 

 

Does it pose a risk to Optimizely working correctly?

 

 

A developer asserts that including un-split script tags could cause problems in some browsers. He believes there is a risk of the code causing other HTML on the page not to work.

 

A popular question about splitting script tags on StackOverflow dates back to 2008 — a time when Amazon and Yahoo did this (they don't anymore). Is this approach out of date?

4WD
Level 1

Re: Should we split the script tags in Optimizely code? Using document.write via tag manager Tealium

Hello 

 

The reason that the development agency is requesting to split the script tag is because it is being loaded using Javascript. What they are trying to account for is making sure when the closing script tag is hit </script> it doesn't close the Tealium script tag as well. Tealium is smart enough now to account for this, however writing in like you have above is perfectly fine as well. All it is doing is concatenating the string then writing it. The output will be the same so it should be fine.

Optimizely