Designaroni
Designaroni

Reputation: 112

Does Google Tag Manager code conflict with Google Analytics code implemented on the same site?

I have a CMS application that universally loads google analytics code. It looks like this & is dynamically loaded in the <head> tag on each of my clients sites.

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-000000-1']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'Product','my-application',3]);
_gaq.push(['_setCustomVar', 2, 'Sport','hockey',3]);
_gaq.push(['_setCustomVar', 3, 'SiteID','121',3]);
_gaq.push(['_setCustomVar', 4, 'State','MN',3]);
_gaq.push(['_setCustomVar', 5, 'DMA','',3]);


(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

My client has implemented Google Tag Manager code just below the opening <body> tag (it looks like this)

<noscript>
<iframe src="//www.googletagmanager.com/ns.html?id=GTM-O8EFGG"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>

<script>
(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','GTM-O8EFGG');
</script>

I am under the impression that my application code will not conflict with the GTM code & vice verse. I want to confirm but haven't been able to dig up information on weather or not these can co-exist or if I need to migrate my UA code into my own GTM code.

Can someone confirm my assumptions are correct, that both the GTM code and the UA codes can run without conflicts?

Upvotes: 1

Views: 3355

Answers (1)

kevintechie
kevintechie

Reputation: 1521

The code shouldn't conflict. However, the tracking results in Google Analytics will be extremely inaccurate unless you're careful not to double-track your page views or events or by sending the data collected by each method to two separate GA accounts.

Upvotes: 1

Related Questions