Google Analytics Campaign Tracking vs. ASPX

Google-Analytics-LogoAs a result of the MyDeco experience (see earlier post), we found that the site in question wasn’t recording campaign tracking (although obviously we can see referring websites). In case you’re not aware of Campaign Tracking, there’s a guide here.

MyDeco are keen for retailers to use campaign tracking to ensure more accurate results with a better quality of data. This is usually done by appending “?partner=mydeco” to the end of any link to the retailer, so that it shows up in their logfiles. If you’re using Google Analytics, this won’t do, as Google wants campaign tracking to be done in its own UTM format (see the guide linked above).

So, we tried this with the site in question, which is hosted on a Microsoft IIS server and written in ASP .NET (.aspx). This had the effect of causing an error – the pages really didn’t like having a query string put on the end of the URL, which is what putting a “?” means. So, we needed a way to get Analytics to accept an alternative character to replace the “?” and thereby stop the website from throwing errors.

The solution, after some searching, was to use the anchor signifier “#” instead of “?”, which the website is happy to accept. However, you can’t just make campaign URLs with “#” instead of “?”, because by default Analytics won’t know what it means. You need to add this line of code to your Analytics tracking code (the code inserted into every page of your website when you set up Analytics):


This line of code should be inserted as follows: Find the Google Analytics code in your webpage and add it like this:

var pageTracker._gat._getTracker(’UA-xxxxxx-x’);

I found this tip courtesy of Digital Notions, so hat-tip to them. 🙂

Leave a Reply