Last active
December 4, 2019 23:29
-
-
Save BaileySimrell/17c55b0fc7a63097c51f5c583641b113 to your computer and use it in GitHub Desktop.
paste in page footer code to replace attribute params dynamically with Webflow CMS data and then send to GA
This file contains hidden or 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> | |
// magical JS snippet | |
$(document).ready(function() { | |
$("[data-gatrack]").each(function(i,item){ | |
var json = JSON.parse($(this).siblings("[ga-track-json]").find('script').text()); | |
var attr = $(this).attr("data-gatrack"); | |
var new_track = attr.replace('{0}',json.provider_name); | |
$(this).attr('data-gatrack', new_track); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment