1

I'm using the excellent UTM-alernative by dm-guy here to create a cookie and inject the campaign source into a form. However, although that works extremely well for the form, the UTM replacement /?src=mybannercampaignsource doesn't show up in Analytics in the Aquisition -> Source/Medium section as it did with the traditional ?utm_source=etc.etc.

My question is whether there is any way to add to the /?src= to include parameters that Google Analytics recognizes, or whether there is some other way of handling this in Google Analytics

  • Hi Chris, if I may ask, why don't you use the good-old utm parameters of google analytics (utm_source, utm_campaign.. and etc.) together with the new "src" query string parameter? – dm-guy Feb 6 '15 at 20:57
1

You need to add JavaScript code before the Google Analytics tracking code to decode the parameters of the URL:

<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
return results == null ? null : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var source = getParameterByName('src');
</script>

and modify GA tracking code to match the parameters with GA standard variables:

ga('create', 'UA-XXXXXXX-YY', 'auto');
ga('set', {
'campaignSource': source,
});
ga('send', 'pageview');
  • Fantastic, works perfectly :) Thankyou very much – user49372 Jan 30 '15 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.