Magazine

How to Easily Use Event Tracking in WordPress with Google Analytics?

Posted on the 15 May 2020 by Nirmalkumar1997

A lot of users got asked for an easy method for event tracking in WordPress. If you are looking for the same, this guide is going to help you!

MonsterInsights is considered as the best Google Analytics WordPress plugin available in the market. If you are not using Google Analytics and any tracking system on your website or blog, you are doing something wrong.

For checking how a user behaves on your website, Google Analytics can help you. It’s a free service offered by Google for tracking websites, mobile applications, etc. And also, the GA comes with a lot of features.

And in this article, we are going to show you how can you enable event tracking in WordPress with some simple steps.

MonsterInsights

monsterinsights plugin

As I mentioned earlier, MonsterInsights is far better than the rest WordPress Google Analytics plugin. The plugin is created by the Awesome Motive team who also developed tools like OptinMonster, WPForms, SeedProd, RafflePress, etc. Plus, MonsterInsights is a freemium product.

In the WordPress plugins repository, you will get a free version so-called MonsterInsights Lite.

monsterinsights lite

As you can see in the above image, the plugin is used on more than 2 million WordPress blogs worldwide. Also, note that the free version plugin comes with only the basic tracking features. You might want to get the premium version if you need to use more advanced tracking features.

You can read our MonsterInsights review for learning more about the plugin and its pricing.

How To Enable Event Tracking In WordPress?

However, we know what’s MonsterInsights from above. Now, let’s see how we can enable event tracking in WordPress.

Plugin Method

First of all, you need to purchase the premium version of MonsterInsights. With the free version plugin, this method is not going to work. If you are planning to do it manually, scroll down to the bottom of this article and we will share something there.

Thankfully, MonsterInsights comes with a feature called Enhanced Link Attribution. This is what we need for tracking the events on our blog.

You might want to modify your link a little bit in this case.

Normally, a link will look like:

<a href="https://www.domain.com/">BUY NOW!</a>

in the HTML format.

We need to make some changes to the format. We will be adding a category, action, and label data-variable tags to the HTML format.

Here’s an example.

<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>

We have set the Custom Category as Category, Custom Action as Action, and Custom label as the Label. And you can change everything according to your liking.

Once you have done editing, save it.

From now on, MonsterInsights will track the link properly, show everything in your MonsterInsights reports section. You can see it from Insights > Reports > Publisher.

How to Easily Use Event Tracking in WordPress with Google Analytics?

Plus, most of us are using affiliate marketing as one of the monetization methods. It is one of the finest and super-easy ways to make money from a blog. If you would like to track your affiliate links in the same way, that’s possible.

You don’t need to track every affiliate link on your blog. For example, let’s say that you have a special landing page on your website that promotes an affiliate product.

For checking how your page performs and how many link clicks are being generated, you could use this feature. Once you have modified the link, you can see the result from your MonsterInsights reports.

event tracking in wordpress

As you can see, everything is simple with the MonsterInsights WordPress plugin.

Manual Method

This might not be a beginner-friendly method. We will be using a little JavaScript here. Normally while you need to add event tracking manually, an onclick parameter will be added to each link.

An example is below.

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

All we need to do is, modify the Category, Action, and Value.

So, the HTML code will look something like this:

<a href="http://domain.com/go" onclick="__gaTracker('send', 'event', 'cta', 'Click', 'Buy button', '0');" >Buy Now</a>

As you can see above, we have changed the Category, Action, Value to something else. And this can be saved.

Also, while you adding a link through the Visual Editor, you won’t be able to add the onclick parameter from there. In that case, you might want to shift it to the Text Editor where you can see everything in the HTML format.

Then, edit the link you need, add the onclick parameter.

Once you have done everything, save the post/ page or custom post type.  It will be good to go.

And when someone clicks on the link or your CTA button, you will be able to track it from your Google Analytics account.

This is how you can enable event tracking in WordPress using the MonsterInsights WordPress plugin or manually. We will always pick the plugin method for making everything easy. Also, no matter you are using Google AMP. MonsterInsights will track those pages too properly without any error.

Get Started With MonsterInsights

You can get the premium version of MonsterInsights WordPress plugin from below.

Get Started With MonsterInsights

$This is an affiliate link

I am pretty sure that it will help you to take your tracking system to the next level.

We hope you have found how can you enable event tracking in WordPress and enjoyed the read. If you did, please consider sharing this article with your friends and fellow bloggers on social media. This will probably help them with the Google Analytics tracking enhancement.

For more WordPress tutorials, plugin reviews, and theme reviews, feel free to check out our WordPress archive page.


Back to Featured Articles on Logo Paperblog