Streaming live at 10am (PST)

Google Analytics event tracking for buttons in Webflow

Hey guys, one workaround to this for the time being is to use the custom code feature to wire up an event handler.

First, give your link some unique ID in the Settings tab:

Then go to your site’s Dashboard, go to the Custom Code section, and add the following example code in the Footer Code section:

  $(document).ready(function() {
    $('#my-unique-link').on('click', function(e) {
      _gaq.push(['_trackEvent', 'Lightbox', 'Open', 'Microsoft Project']);

If you have a lot of these all across your site with different parameters, you can create a common handler that keys off of allowed custom attributes, like so:

First add a data-gatrack attribute to the links you want to track. You can call it whatever you want, but it should start with data- and it must match the script (shown below) exactly.

Then add the following more-generic click handler to the Footer Code of your site:

  $(document).ready(function() {
    $(document).on('click', '[data-gatrack]', function(e) {
      var $link = $(this);
      var trackData = $'gatrack');
      if (!trackData) { return; }
      var trackParams = ['_trackEvent'].concat(trackData.split(','));

Note that attribute names here are case-sensitive, so if you set your custom attribute to something like data-gaTrack and don’t update the script to reflect that, it won’t work.


Thank you guys, I tried the first option and it works! Thank you so much!

@callmevlad. Does your second option here work on tracking light box clicks? Can’t seem to get it work. Do you still need to add a unique I’d as in the first option?

Too complex for me to accomplish this in a short period. Can you post an exemple that will work with localize.js instantly?
Thanks again.

Hi! Please, update us on what’s going on! :slight_smile: We still not able to use “onclick” attribute? And what to do? How to track an events directly, without “workarounds”?

Hi this doesn’t seem to be working. I’ve set up exactly as you’ve described here and I’m not getting anything register on my Analytics account. You can see from this image that link settings are set up correctly:

You can see from this image that the snippet is in my footer.


Any ideas on how I can fix this? I really need to start tracking button clicks.


1 Like

Forget that, it must have taken a few minutes to register as it wasn’t showing on live analytics but it is now.

How to make correct script for Universal Google Analytics?

Doesn’t work((

1 Like

This topic was automatically closed after 24 hours. New replies are no longer allowed.

Hey guys! Any news to add atribute onClick for buttons? It seems they doesnt works…

yes, they don’t. the workaround is to place a GTM container inside the < body > and to create Event tags in the Google Tag Manager.
It works fine for me.


I tried option 2 here with the generic click-handler in the footer code and it’s not working, at least as far as I can tell with the tag assistant. (

I am not able to track the Form Submission of my website even after using onclick event. Do I need to do anything else after the code?

I’m still not able to get any event tracking… Has anyone has luck with Event Tracking in Webflow? (without the Google Tag manager)

Hi, I am trying to use this solution on my website. Please could you advise where in Google Analytics will the data collected from this show? Thanks

1 Like

I am also having an issue to get this solution to work, would really appreciate if someone could help directly as we will be needing GA on a number of sites, and link tracking is very important and I have tried all of the suggested solutions, yet nothing appears to be working? Thanks


It’s almost one year… We still have to add the onclick tracking event manually right? Theres any other way?


I am still waiting for a solution for this also.