Google introduced gtag.js for a streamlined event tracking process, which has caused some tracking issues in Webflow. Here’s how to address it:
1. Understand gtag.js Requirements
- gtag.js is the latest Google Analytics tracking code needed for setting up event tracking on your website.
- This requires migrating from the older analytics.js or universal analytics setup to gtag.js.
2. Update Your Google Analytics Script in Webflow
- Go to Project Settings in your Webflow dashboard.
- Navigate to the Custom Code tab.
- Replace the current Google Analytics script with the gtag.js script provided by Google. Ensure it's placed in the Head Code section.
3. Define Events in gtag.js
- Use the gtag('event', [event name], { [event parameters]}) format for event tracking.
- Example: to track a button click, use
gtag('event', 'buttonclick', {'buttonid': 'signup_button'}).
4. Implement Event Tracking in Webflow
- Open the Designer and select the element you want to track (e.g., a button).
- Add an OnClick interaction with Custom Code.
- Use the defined event format from Step 3.
5. Test Your Event Tracking
- Publish Your Website to make the changes live.
- Use Google Tag Assistant or Real-Time Events in Google Analytics to verify that events are being tracked.
6. Ensure Correct Event Tags
- Double-check that all event names and parameters used in your code are correctly spelled and formatted.
Summary
Switch to gtag.js in Webflow by updating your analytics script in the Custom Code section of Project Settings. Define and implement specific event tracking manually using gtag.js syntax, and verify functionality via Google Analytics tools.