Reputation: 58412
I have a site that is using jQuery 1.11.0 as it needs to still support ie8 (I know it's ridiculous, but the client wants it as they are dinosaurs and still use it throughout their company), but I have a bug where none of my functions were working after a particular point and after a lot of debugging, I have tracked it down to google tag manager downloading the jquery 2.1.5 library.
This is conflicting with my current library and removing all the functions from the jQuery.fn.
and causing my site to crash.
I've read that gtm will download jquery if it can't find a library or deems the old library too old. Does anyone know how to stop this conflict or stop gtm downloading the jquery file?
My current call to tag manager is like this:
//Google tag manager
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'//www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'XXX-XXXXXX');
Is there anything I can add to this or change it?
I should also say that I am unable to use noConflict
and changing the jQuery var name for the current code as it is using a cms there are some scripts I am unable to change
Upvotes: 0
Views: 1687
Reputation: 58412
As it turns out GTM doesn't actually download jQuery as I was lead to believe in other posts on the subject. Instead, you can write bespoke code for GTM to track certain things; and as such the marketing company that manages the account had written some form abandonment tracking code that caused the GTM script to download the extra jQuery library.
So if like me you don't touch that side of the GTM, the first thing you need to look at if you have the same issue, is your marketing company's bespoke code!
Upvotes: 1