How to Set Up Google Analytics Events Tracking in WordPress

Google Analytics lets you track everything on your site. Here is how to set up Google Analytics Custom Events Tracking to measure events in WordPress.

Tracking events can be really helpful if your site provides various ways for users to interact. Google Analytics helps you track such events, for example, tracking file downloads.

The setup process is a bit tricky, especially if you lack a technical hand. But if you are a WordPress user, then MonsterInsights make your life easier.

Today, I’m sharing how you can easily set up Google Analytics custom events tracking in WordPress. I’ll share two methods:

  • Method #1: Using MonsterInsights (easy)
  • Method #2: Traditional Custom Set up (little complex)

Now it depends on you which method you go with. Both get the job done 😉

Before getting started with the process, let’s discuss a little bit about Custom Events in Google Analytics.

What are Custom Events in Google Analytics?

Google Analytics lets you track anything related to your site. One of the awesome functionalities it provides is tracking custom events.

Websites (including yours) provide their users with various ways to interact like downloads, button clicks, video plays, purchases, etc.

Using Custom Events, you can track how many times a user has interacted with your site’s content. It is highly necessary to know that so that you can scale your strategy.

For instance, if you are selling an eBook on your site. Then setting up the custom events tracking can help you track how many times the “Buy Now” button is pressed.

Or, if you are providing the eBook for free, then you can know how many times the users have downloaded it.

Now, every event has 3 major components that help ease your tracking:

  • Event Category: It is the name of the object users interact with. Eg. “CTA” for call-to-action buttons.
  • Event Action: It is the name of the type of interaction. Eg. “Click” for clicking on the buttons.
  • Event Label: Additional information about the events you want to track. Eg. “Buy Now” for your sidebar button.

So, once you define all the three components in your custom event, it starts tracking all the necessary info.

Let’s move on to the next part and set up Google Analytics Events Tracking in WordPress.

Set up Google Analytics Custom Events Tracking in WordPress

As mentioned above, we have 2 methods for this task. Starting with the easy one below.

Method #1: Using MonsterInsights

MonsterInsights makes Google Analytics easy! This plugin has many rare features like it makes it possible to add a Google Analytics stats dashboard in WordPress so that you don’t have to leave your site to get the site’s insights, track scroll depth to analyze user retention, and track authors in WordPress.

MonsterInsights

MonsterInsights recently introduced a new Custom Link Attribution feature to allow you easily add custom event tracking to your custom links. So, update your MonsterInsights plugin to get the new feature.

With this new feature, you can track your call-to-action (CTA) buttons and find out how well your site’s conversions are doing.

It’s literally a one-step procedure to add custom event tracking to your custom WordPress links with MonsterInsights.

All you need to do is to add the following data-variable tags to the HTML of your link:

  • For Event Category, use: data-vars-ga-category="Custom Category"
  • For Event Action, use: data-vars-ga-action="Custom Action"
  • For Event Label, use: data-vars-ga-label="Custom Label"

This is how your final code should look like:

<a href="https://www.example.com" data-vars-ga-category="Custom Category" data-vars-ga-action="Custom Action" data-vars-ga-label="Custom Label">Example</a>

MonsterInsights will start tracking the event once all the variables are added to any of your site’s links.

You can modify Custom Category, Custom Action, and Custom Label in the above code as per your requirements.

For instance, if you want to track the clicks on a button then use the following:

  • CTA instead of Custom Category
  • Click instead of Custom Action
  • Buy Now instead of Custom Label

Now to view the data from your custom event tracking link, head over to Insights » Reports » Publisher. Next, scroll down and view the Top Outbound Links report for outbound links.

MonsterInsights Top Outbound Links Report

Not only that, if you use the tracking variables for affiliate links, then you can check the Top Affiliate Links report too.

MonsterInsights Top Affiliate Links Report

Custom Link Attribution feature also supports Google AMP pages. That way, you can easily track your AMP optimized custom links too.

Method #2: Traditional “onclick” Parameter Set up

If you don’t want to use MonsterInsights plugins and use the traditional method, then go ahead. We’ll use the onclick parameter for this trick.

Also, you need some knowledge of Javascript for the best implementation.

Below is the onclick parameter we will use:

onclick="__gaTracker('send', 'event', 'category', 'action', 'label', 'value');"

Now you need to replace category with your Event Category, action with your Even Action, and label with your Event Label. This is how the final result should look:

<a href="http://yoursite.com/pricing" onclick="__gaTracker('send', 'event', 'CTA', 'Click', 'Buy Now', '0');" >Buy Now</a>

That’s all! Google Analytics will start tracking your custom events when your site’s visitors click the button.

Frequently Asked Questions

I hope this article helped you to learn how to set up Google Analytics custom event tracking in WordPress. If you have any doubts, then feel free to ask them in the comments section below.

2 thoughts on “How to Set Up Google Analytics Events Tracking in WordPress”

  1. Avatar

    Thanks for sharing the great tips to set up Google Analytics event tracking in a WordPress site

Leave a Comment

Your email address will not be published. Required fields are marked *

Share via
How to Set Up Google Analytics Events Tracking in WordPress
Scroll to Top
Send this to a friend