Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save onemanparsons/70e2355228968af2fb3b020a32e577af to your computer and use it in GitHub Desktop.
Save onemanparsons/70e2355228968af2fb3b020a32e577af to your computer and use it in GitHub Desktop.
Get UTM parameter values and run script
// Get all URL parameters
function getUrlParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
// Set utm_campaign
var utm_campaign = getUrlParameter($param);
if (utm_campaign) {
// some code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment