Hey guys
Seems like the event tracking stopped working after google introduced the new gtag.js any idea how I can continue tracking events?
Thanks
Hey guys
Seems like the event tracking stopped working after google introduced the new gtag.js any idea how I can continue tracking events?
Thanks
I donāt know about gtag.js (which is specially purposed for webshops), but the new version for ānormal useā is ga.js (there is a switch in the settings/integrations page of Webflow). You can implement it almost as in the āoldā way as described in: Google Analytics event tracking for buttons in Webflow - #27 by WFHelp_FF
but you need to change the code in the footer to:
<!-- Start of Google Analytics Event tracking code -->
<script>
$(document).ready(function() {
$(document).on('click', '[data-gatrack]', function(e) {
var $link = $(this);
var trackData = $link.data('gatrack');
if (!trackData) { return; }
var trackParams = ['send', 'event'].concat(trackData.split(','));
ga.apply(null, trackParams);
});
});
</script>
<!-- End of Google Analytics Event tracking code -->
need more data on this
iāve tried following those instructions exactly, and used the code from this post
no events being triggered in google analytics
any help?
Iāve been attempting to fix the same problem: trying to record events in google analytics from webflow.
Iāve managed to find a solution by doing the following:
Donāt use webflowās google analytics integration under their āIntegrationsā tab. Instead, paste googleās Global Site Tag (gtag.js) into your siteās <head>
tag (under webflowās āCustom Codeā tab).
Paste the following code into the āFooter Codeā section of webflowās āCustom Codeā tab:
<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>
Go to an element you want to track an event on (like a form button), and add a āCustom Attributeā with the following format: Name = data-gatrack
Value = yourEventCategory, yourEventAction, yourEventLabel
@alexvale, thanks alot for sharing this !
@alexvale how can you add a āNameā custom attribute to a form button? Looks like this is not possible (anymore?)ā¦
Thanks for your help!!
@marky when you click the ā+ā button under Custom Attribute it will come up with a popup that looks like the image below. There should be 2 fields, āNameā and āValueā.
Thanks for this solution, @alexvale!
Iāve implemented it but canāt tell if itās working. How would you go about testing to see if it works?
Hereās what Iāve done:
Added gtag.js script to site head
Added your code to site footer
Added data-gatrack
attribute to my test button
Checked GA Events
Tried using GA Debug and Event Tracking Tracker Chrome extensions, but couldnāt figure out how to test for successful tracking
What am I missing?
And how would you go about testing?
Thank you for this Alex. Worked like a charm.