: 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.
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
More posts by @Samaraweera270
1 Comments
Sorted by latest first Latest Oldest Best
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');
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.