Forked from cgilchrist/replace_text_with_url_param.js
Created
January 18, 2013 06:14
-
-
Save iloris/4562707 to your computer and use it in GitHub Desktop.
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
<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