Created
December 4, 2019 23:28
-
-
Save BaileySimrell/f62133c558c7f5364142c935c0101ed2 to your computer and use it in GitHub Desktop.
paste this code in the footer of your site's settings within Webflow to send event data to GA from Webflow attributes
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
<!-- Start of Google Analytics Event tracking code --> | |
<script> | |
$(document).ready(function() { | |
$(document).on('click', '[data-gatrack]', function(e) { | |
var $link = $(this); | |
var commaSeperatedEventData = $link.data('gatrack'); | |
var eventParams = commaSeperatedEventData.split(','); | |
if (!eventParams) { return; } | |
eventCategory = eventParams[0] | |
eventAction = eventParams[1] | |
eventLabel = eventParams[2] | |
gtag( | |
'event', | |
eventAction, | |
{ | |
'event_category': eventCategory, | |
'event_label': eventLabel | |
} | |
) | |
}); | |
}); | |
</script> | |
<!-- End of Google Analytics Event tracking code --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment