The UTM (Urchin Traffic Monitor) tracking code is used to track traffic source, medium, and campaign; and allows businesses to track conversion funnel from referral site. With the introduction of Google Tag Manager, some folks are unclear how to implement UTM tracking codes into their HTML pages. The following two simple steps will guide you through installing the UTM javascript snippets into your web pages.

1. Add the classic Google Analytics library, ga.js from Google CDN.

<script src="//www.google-analytics.com/ga.js"></script>

2. Login to your Google Analytics account, and get your GA code snippet.

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

  (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>

Add ga.js and your Analytics tracking code at the bottom of your HTML page just before the closing </body> tag.

Note: The ga.js is an old classic Google Analytics library, which is different than the newer Universal Analytics (analytics.js). Including the ga.js on your page will not create UTM cookies, but including the latter GA code snippet (particularly ga('create', 'UA-XXXXX-Y', 'auto');)will cause it to create the UTM cookies in client's computer.

Share this post

Comments (0)

    No comment

Leave a comment

All comments are moderated. Spammy and bot submitted comments are deleted. Please submit the comments that are helpful to others, and we'll approve your comments. A comment that includes outbound link will only be approved if the content is relevant to the topic, and has some value to our readers.


Login To Post Comment