Looking for feedback on JS script that automatically tries China CDN when main CDN fails.

Silver Contributor
Silver Contributor

I have created the following script in an attempt to automatically load the China CDN if the Main CDN fails to load. The idea is to provide a single script that will work globally including users in China from the same page..

<script type="text/javascript">
a='//tags.tiqcdn.com/utag/account-name/profile/prod/utag.js';
b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
d.onerror = function() {
    a='//tags.tiqcdn.cn/utag/account-name/profile/prod/utag.js';
    b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
    a=b.getElementsByTagName(c)[0]; a.parentNode.insertBefore(d,a);
}
a=b.getElementsByTagName(c)[0]; a.parentNode.insertBefore(d,a);
</script>

I am looking for feedback on potential issues anyone could see with the above method not working on browsers or mobiles.

 

.
2 REPLIES 2

Looking for feedback on JS script that automatically tries China CDN when main CDN fails.

Tealium Expert
Tealium Expert
Hi @AndrewFenn - what issues are you experiencing/attempting to solve, and have you seen this thread: https://community.tealiumiq.com/t5/Tealium-iQ-Tag-Management/Tealium-China-Tracking-China-CDN/m-p/27...
Tealium Expert

Looking for feedback on JS script that automatically tries China CDN when main CDN fails.

Silver Contributor
Silver Contributor

@mitchellt wrote:
Hi @AndrewFenn - what issues are you experiencing/attempting to solve,

I mentioned it in the original post...

> The idea is to provide a single script that will work globally including users in China from the same page..

Right now users in China will get a DNS error on the .com version of the tag, but not for the .cn version. We have confirmed this. Surprisingly these issues only exist with TealiumIQ. The .com on Tealium Collect seems to work without issue.

.
Public