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"> | |
<!-- | |
function setCookie(name, value, days) { | |
var date = new Date(); | |
date.setTime(date.getTime() + (days*24*60*60*1000)); | |
var expires = "; expires=" + date.toGMTString(); | |
document.cookie = name + "=" + value + expires; | |
} | |
var query = window.location.search.substr(1); | |
if (query.length > 0) { | |
var params = query.split("&"); | |
for (var i=0; i<params.length; i++) { | |
var pos = params[i].indexOf("="); | |
var name = params[i].substring(0, pos); | |
if (name == "gclid") { | |
var value = params[i].substring(pos + 1); | |
setCookie(name, value, 90); | |
} | |
} | |
} | |
function readCookie(name) { | |
var n = name + "="; | |
var cookie = document.cookie.split(';'); | |
for(var i=0;i < cookie.length;i++) { | |
var c = cookie[i]; | |
while (c.charAt(0)==' '){c = c.substring(1,c.length);} | |
if (c.indexOf(n) == 0){return c.substring(n.length,c.length);} | |
} | |
return null; | |
} | |
window.onload = function() { | |
document.getElementById('AdWordsID ').value = readCookie('gclid'); | |
} | |
--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment