Google Analytics and Site Tag Usage - HTML HEADER

Hello. We have a google analytics script in our header:

<!-- Global site tag (gtag.js) - Google Analytics -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=UA-134427814-1"></script>
	<script>
	  window.dataLayer = window.dataLayer || [];
	  function gtag(){dataLayer.push(arguments);}
	  gtag('js', new Date());

	  gtag('config', 'UA-134427814-1');
	</script>

One of our marketing folks asked us to add their AdWords script into the header, but the information looks VERY redundant aside the gtag and the script.

<!-- Global site tag (gtag.js) - Google Ads: 688431405 -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=AW-688431405"></script>
	<script>
	  window.dataLayer = window.dataLayer || [];
	  function gtag(){dataLayer.push(arguments);}
	  gtag('js', new Date());

	  gtag('config', 'AW-688431405');
	</script>

My question is, how do I properly set this up? Do I just add gtag(‘config’, ‘AW-688431405’); and script to the current snippet? Or do I have to run both snippets separately?

I haven’t deal with Google ads yet but I think for proper code working they should be separated otherwise it can effect the statistics.

It looks like you can do that. The scripts are identical except for the account IDs, so mostly redundant.
So you can just add a second gtag line for the AW account, as shown here:-
https://developers.google.com/gtagjs/devguide/add

1 Like