How can I integrate Google Analytics into my Webflow website and track specific button clicks using the event tracking feature?

TL;DR
  • Embed Google Tag Manager in Webflow via the Custom Code section and link it to Google Analytics 4 using your measurement ID.  
  • Create custom click triggers in GTM for tracked buttons using unique IDs or classes, define GA4 event tags with parameters, then test with GTM Preview mode and confirm in GA4 Reports.

To integrate Google Analytics into your Webflow website and track specific button clicks, follow these steps using Google Analytics 4 (GA4) and Google Tag Manager (GTM), which is the recommended setup for advanced event tracking.

1. Add Google Tag Manager to Webflow

  • Sign up or log in to Google Tag Manager, and create a new container for your Webflow site.
  • Copy your GTM container ID (format: GTM-XXXXXXX).
  • In Webflow:  
  • Go to your Project Settings > Custom Code tab.
  • Paste the GTM head and body snippets into the respective sections.
  • Click Save Changes and Publish your site.

2. Connect GA4 to Google Tag Manager

  • In Google Analytics, navigate to Admin > Data Streams > Select your Web Data Stream.
  • Copy the Measurement ID (starts with "G-").
  • In Google Tag Manager:
  • Go to Tags > New > choose Google Analytics: GA4 Configuration.
  • Paste the Measurement ID, set the trigger to All Pages, and Save the tag.
  • Click Submit and Publish the GTM Container.

3. Add Event Tracking for Button Clicks

  • In GTM, go to Triggers > New > choose Click – All Elements or Click – Just Links depending on the button type.
  • Set the trigger to fire on Some Clicks, and define criteria (e.g., Click Classes equals btn-contact).
  • For your button in Webflow:
  • Select the button and go to Settings Panel (gear icon).
  • Add a unique ID or class name (e.g., btn-contact) for easy targeting.
  • Go to Tags in GTM > New > select GA4 Event.
  • Choose your GA4 config tag.
  • Set Event Name (e.g., contactbuttonclick).
  • Under Event Parameters, add key-value pairs like:
    • Parameter Namebutton_nameValueContact Us
  • Set your custom trigger created earlier.
  • Save and publish the container.

4. Preview and Test

  • Use GTM’s Preview Mode to test your implementation.
  • Click the button on your published site and confirm the event is firing in Tags under Preview tools.
  • Verify in GA4:  
  • Go to Reports > Events, or use Realtime report to spot your custom event.

Summary

To track button clicks with Google Analytics in Webflow, embed Google Tag Manager into your site, connect GTM to GA4, and define custom click triggers and events in GTM for the buttons you want to monitor. Testing with Preview Mode ensures proper setup before checking data in GA4 reports.

Rate this answer

Other Webflow Questions