SEO Friendly Google Analytics Campaign tracking with Hash Marks

hash-mark-campaign-trackingWhen it comes to campaign tracking, Google Analytics is very good at doing that.  Campaign tracking is relatively easy, but in some cases campaign tracking parameters may cause duplicated content problems, so in order to prevent duplicated content problem I recommend adding hash marks.

Original URL:
URL with campaign tracking parameters

The question mark right after the .html makes campaign tracking URL crawlable and if this page is not protected it will get crawled and indexed by all major search engines once it gets exposed.

In order to prevent duplicated content I recommend using a hash mark (#) in the query parameter, instead of a question mark (?). When Google finds a URL with a hash mark (#), it ignores everything after the hash.

Updated Campaign tracking URL

Google Analytics to interpret this change correctly you also need to enable Anchor tracking by adding the following line of code to your tracking code


Live example:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);

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


If you need help building search engine friendly campaign tracking URLs i recommend using Campaign Tracking URL Builder

About Peter Voynov

Technical SEO & Web Analytics Specialist @ Peter Voynov LinkedIn