Last active
August 16, 2017 15:39
-
-
Save dillansimmons/c85eee39e3f484528912527c7766bd3b to your computer and use it in GitHub Desktop.
Parse URL values
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
// JS for grabbing utm params | |
var getRefQueryParam = function() { | |
var temp = {}; | |
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() { | |
var decode = function(s) { | |
return decodeURIComponent(s.split("+").join(" ")); | |
}; | |
temp[decode(arguments[1])] = decode(arguments[2]); | |
}); | |
return temp; | |
}; | |
// Get all the UTM parameters before the page finishes rendering | |
var utmParamQueryString = '', | |
utmParamQueryStringTrimmed = '', | |
utm_code = ''; | |
(function() { | |
utm_code = getRefQueryParam("utm_code"); //Renders the value in url if it is present ie .com?utm_code=Charlie *renders 'Charlie' | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment