Skip to content

Instantly share code, notes, and snippets.

@BaileySimrell
Last active December 4, 2019 23:29
Show Gist options
  • Save BaileySimrell/17c55b0fc7a63097c51f5c583641b113 to your computer and use it in GitHub Desktop.
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
<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