Last active
August 29, 2015 14:13
-
-
Save cougrimes/1cff746d9beb19da267f to your computer and use it in GitHub Desktop.
Parse Google Analytics parameters as JS variables
This file contains 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
var getURLParams = 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; | |
}; | |
var $_GET = getURLParams(); | |
var utmMedium = getURLParams()["utm_medium"]; | |
var utmSource = getURLParams()["utm_source"]; | |
var utmCampaign = getURLParams()["utm_campaign"]; | |
var utmTerm = getURLParams()["utm_term"]; | |
var utmContent = getURLParams()["utm_content"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment