Navin Rao

How to Add Google Analytics Event Tracking in WordPress

Adding custom event tracking in Google Analytics is the way to analyze your website performance. Creating events in Google Analytics will help you evaluate all your crucial links and strategize the content.

In this article, I will walk you through how to add Google Analytics custom event tracking in WordPress easily.

I understand setting up the technical aspects of a WordPress website is not easy for non-techies at all. But, I will make sure it to a cakewalk for you.

We will be using the MonsterInsights plugin in this article to add Google Analytics events.


Add Google Analytics Custom Events Tracking in WordPress

As you might already know, Google Analytics is made to track page views and users coming into the website. That means you will get an overall measurement of your website performance.

But, what if you would like to know how a particular page is performing and how your users are behaving with your content?

Understanding user interactions is the best way to optimize your content. Eventually, it will allow you to make more sales.

Well, there are two fantastic ways to add Google Analytics custom events tracking to the WordPress website.

  • Adding Custom Link Tracking with MonsterInsights (Perfect for non-techies)
  • Adding an on-click Parameter on your Link Manually

We will see both of them so that you can choose the one you would prefer. But I found the first one, adding custom events tracking through monster insights would be the easiest one.

Most folks prefer to do so, as there are more advantages with that awesome tool in terms of extracting deeply detailed data.

Let’s hop in, and see the first method in action.


Add Custom Link Tracking with MonsterInsights – Method 1

MonsterInsights is certainly a perfect fit for both beginner and advanced-level users to track Google Analytics, no wonder why people call it the best Google Analytics WordPress plugin. It deserves all those noises.

That’s the reason, many large-scale businesses rely on the tool’s in-depth and detailed statistics. The plugin presents the whole data in rich graphics,

MonsterInsights Plugin is being regularly updated and their custom link attribution feature will also allow you to track the user’s behaviors for your Call To Action.

Sounds great, isn’t it? This will help you track the user’s behaviors and Optimize those calls to action for making more sales and conversions.

Create and Edit Custom even Tracking Links

1. Install the MonsterInsights WordPress Plugin, and follow the setup wizard, which is super easy.

Adding event tracking for your custom WordPress links is super easy. You just need to edit your links and add some variable tags,

Here is an example tag that might 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>

Once you add the tags to your WordPress links or any call to action, MonsterInsights will start tracking those links. And shows you the detailed report right from your WordPress Dashboard.

For instance, if you want to create a call to action for your Sidebar Widget to sell WordPress Hosting. I will show you how you can add custom event tracking for the same. The product pricing page would be, https://navinrao.com/visit/generatepress

Understand the event conditions in this scenario, to add custom even tracking links in your site.

  • Category: “cta”
  • Action: “Click”
  • Label: “Visit SiteGround”

Now in this scenario, you need to edit your variable tags category, action, and labels with your desired ones.

<a href="https://questioncage.com/visit/siteground" data-vars-ga-category="cta" data-vars-ga-action="click" data-vars-ga-label="Buy button" >Visit SiteGround</a>

We are all done. Let MonsterInsights do the remaining job for you to make more conversions.

2. To view all the links data, head over to WP Dashboard >> Insights >> Reports >> Publisher >> Top Outbound Links

There you will find all the data along with some default event tracking options.

  • Events tracking
  • Enhanced Link Attribution
Google Analytics Event Tracking

You can also view your affiliate links data if you have created event tracing links for even those.

  • Affiliate Link Tracking Options,
Affiliate Link Tracking

And if you have a small downloading section for your e-books, freebies, premium stuff, and probably some other stuff, those are trackable too.

File Download tracking (popular formats)

File Download Tracking

Add On-click Parameter on Your Link – Method 2

Well, the above one is a robust method to track links, but if you want to try another way, it exists too.

Probably a little more Java skills are required to implement. Let’s add custom WordPress event tracking using an on-click parameter.

Here is an instance of the on-click parameter

onclick=”__gaTracker(‘send’, ‘event’, ‘category’, ‘action’, ‘label’, ‘value’);”

Considering this instance, we will replace or edit on click tags category, action, and value with the event conditions that we implemented earlier.

I have done the job for you and our final Call to action would look like this,

<a href="https://questioncage.com/visit/siteground" onclick="__gaTracker('send', 'event', 'cta', 'Click', 'Buy button', '0');" >Visit SiteGround</a>

Whoa, we are all good now.

Now, your sidebar widget is all set to get tracked. MonsterInsights will track custom events for every link you have created not only the sidebar, whenever the users click on those.

So, I am pretty sure now, that you have learned two ways of how you can add Google Analytics event tracking in WordPress.

Follow the process for all your website and see the magic, in terms of conversions.

Recommended read: How to Stop Google Analytics to Track My Own Visits

Leave a Reply

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