Created
May 14, 2021 15:04
-
-
Save onemanparsons/70e2355228968af2fb3b020a32e577af to your computer and use it in GitHub Desktop.
Get UTM parameter values and run script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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