Question
Track campaigns with Google Analytics without query string parameters?
Is there a supported way in Google Analytics to track a campaign without having to use query string parameters.
In Analytics you can tag a link to your site with query string parameters such as utm_campaign
and utm_medium
which carry information about the campaign so that they can be tracked.
Google actually has an online tool to help in the creation of such links.
For instance if StackOverflow was advertising on Experts Exchange they may have a link like this :
For many reasons I don't want these clumsy looking parameters appearing in my URLS :
- I want to encourage twittering, and long links discourage this
- I dont want people bookmarking them with campaign IDs in
- I want people to see a clean URL
- I dont want search engines indexing these links.
- I want full control about what parameters are sent to google analytics - and not leave it up to my partners to mess up the URLs they access my site with
I looked a while ago to try to find a way wherein you could set these parameters. Google has a page which at first glance looks like the solution, but actually isn't. That page describes how you can change the names of the query string parameters to something else - for instance to use src
instead of utm_source
you would run :
pageTracker._setCampSourceKey("src");
I really cannot seem to figure out why they don't make it easy to actually explicitly set the value of the utm_source
key - and not just set up an alternative parameter name for it.
I remember a while back finding someone who had a kind of nasty hack, but I cant even seem to find that now. I seem to recall though that whoever it was took a copy of the analytics code and essentially branched it off and hacked at it. This is not a good solution for me!
is there an officially supported way of doing this at all, without some kind of nasty redirects.
In a nutshell I want to do something like this (ASP.NET MVC site). Give a partnet a link to my site with a URL like this :
http://www.example.com/?cid=2dae88a8-66b1-475d-8a35-2978bd1a158c
In the controller for my MVC page I would find out what campaign this GUID related to, and set the model state. Note: this gives me the advantage that i can change the campaign parameters without having to reissue the URL.
In the page itself I would then do this:
var campaignMedium = <%= ViewData.Model.CampaignMedium %>;
var campaignSource = <%= ViewData.Model.CampaignSource %>;
var campaignName = <%= ViewData.Model.CampaignName %>;
pageTracker._setCampaignData({
utm_source: campaignSource,
utm_medium: campaignMedium,
utm_campaignName: campaignName
});
pageTracker._trackPageview();
IMPORTANT: This _setCampaignData method DOES NOT ACTUALLY EXIST. This is just 'pseudo code' for what I'd ideally like to be able to do.
Has anyone successfully managed to do anything like this?