Skip links

Click Tracking for Google Analytics GA4

Click tracking helps you to send events to Google Analytics when a visitor clicks a specific element on the page.

This could be a:

  • Banner
  • Button
  • Expand button
  • Text

Basically, any element on the page.

Before you create the event tracking for your element, you will have to choose between two types of events in Google Analytics.

  1. Recommended Event → These are pre-defined events that Google recommends that you use if possible. They have an event name and a set of named parameters that represent metrics and dimensions.
  2. Custom Events → You choose the event name and parameters.

It’s up to you to choose which type makes sense for your use case, but I suggest reviewing the recommended events list first. Otherwise, create a Custom Event.

How to create Recommended or Custom Events

To learn more about how to create recommended or custom events, read the following knowledge base article: Creating Custom or Recommended Events

Example – Tracking a button? #

Let’s say that we want to track how many visitors clicked our Download button on a landing page.

Our first step is to identify this button, and for that, we are going to give it a unique class:

In the block editor, you can expand the Advanced section of the block to add CSS classes.

You can see that I added the class btn-cta. We are going to use this class when we create the event.

Once we save this button block, we can head to the plugin’s Click Tracking tab and create a new event.

Creating the event #

In the Click Tracking tab, click the Add Custom Event button (The recommended events list doesn’t have an event that suits this use case).

We can then fill in the event information:

Custom Event Name → brochure_download

Class or ID Selector → .btn-cta

Note the dot “.” character before the class name.

Then I added two additional properties:

page_title → Demo

brochure → Blue Modern Brochure Sea Travel Trifold Brochure

It should look like this:

That’s it. From that point, whenever a visitor click this button, the plugin will fire up an event and send it to Google Analytics.

Creating a new custom dimension in Google Analytics #

Now that we set up this event, there is one more thing to configure.

We used two parameters for this event:

  1. page_title
  2. brochure

page_title is a built-in dimension in Google Analytics GA4, but “brochure” isn’t.

If we want to be able to use this dimension in our reports, we will have to create it.

To create it, we will go to the Configure → Custom definitions page in Google Analytics and create a new custom dimension:

Ensure that the Scope is set to Event and that the Event Parameter matches the name of the property you added to the plugin.

Once you create the new dimension, you will be able to use it in your reports.

Powered by BetterDocs