Skip to content

Instantly share code, notes, and snippets.

@measureschool
Created September 3, 2018 13:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save measureschool/4387f71dc26f5d08919857d7afe5e5d6 to your computer and use it in GitHub Desktop.
Save measureschool/4387f71dc26f5d08919857d7afe5e5d6 to your computer and use it in GitHub Desktop.
<script>
(function () {
var url = "https://script.google.com/macros/s/AKfycbyqqd-NuGVuYVz0MK9KNoLgP5V7Ny9sdde0y4M1tBWYr6jWDb7rxI7g/exec" //replace with your AppsScript URL
var hash = "{{url - acid}}" //replace with your Variable name in two curly brackets {
function httpGetAsync(requestURL, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", requestURL, true); // true for asynchronous
xmlHttp.send(null);
}
try{
httpGetAsync(url+"?acid="+hash, function(data){
var userData = JSON.parse(data);
userData["event"] = "acUser";
dataLayer.push(userData);
});
}
catch(e) {
return e;
};
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment