Mobile app version of vmapp.org
Login or Join
Samaraweera270

: UTM-alternative for adding parameters with exiting Analytics campaign terms I'm using the excellent UTM-alernative by dm-guy here to create a cookie and inject the campaign source into a form.

@Samaraweera270

Posted in: #Cookie #GoogleAnalytics #Tracking #UrlParameters

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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ravi8258870

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');

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme