Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iloris/4562707 to your computer and use it in GitHub Desktop.
Save iloris/4562707 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
var getUrlParams = function() {
var params = {}, hash;
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&');
for (var i=0; i<hashes.length; i++) {
hash = hashes[i].split('=');
params[hash[0]] = hash[1];
}
return params;
};
jQuery(function() {
// This assumes you have a parameter in your URL called "utm_keyword"
var utm_keyword = getUrlParams()['utm_keyword'];
if (utm_keyword != undefined) {
// This assumes you've given an element on the page and ID of "keyword"
jQuery('#keyword').html(utm_keyword);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment