Last Updated on June 29, 2020 by Roshan Parihar
Do you want to use event tracking with Google Analytics on your WordPress website?
Event tracking is one of the best features of Google Analytics to track the events on your website. You can analyze the events and record to find which element provides you the best result.
In this post, you will learn how to make event tracking with Google Analytics. MonsterInsights is the best WordPress plugin to easily track the events and analyze the performance of the elements.
Let’s find out the easiest ways of tracking events with Google Analytics and check analytics data.
Affiliate Disclosure: At Tutorialdeep, we believe in transparency for our users. In this blog, there are some referral links. If you signup with these links we will earn some commission with no extra cost to you. We recommend these links because these are our trusted brands.
What is Event Tracking in Google Analytics?
Event tracking is the advanced feature of Google Analytics to easily track the user’s activity on websites. There can be many events on a website like a file download, button click, link click, page scrolling, image click, and many others.
Tracking events can help you find the most important items of your website that can generate more conversions. Events are the important analytic data for your website to analyze the traffic behavior with your content. You can improve your content according to the analytic data to get more traffic and sales.
Why You Should Use Event Tracking with Google Analytics?
Affiliate Links or OutBound Links Tracking: If you are an affiliate marketer and earning money from affiliate marketing. You can easily track your outbound links and find out the visitors that clicked the affiliate links on your website.
Track Number of Clicks on a Call-to-Action Button: If you have a buy now button or form submission button, you can find the number of clicks you are getting each day in these buttons. This can help you to increase your chances of optimizing your content for more conversions and sales.
Ad and Banner Click Tracking: Find the number of clicks on your ads and banners to find the correct position of ads to get more clicks. You can also get which banner getting more clicks and you earn money from it on your website.
Tracking Number of Downloads: If you have any digital products to download from your website, you can track the clicks and number of downloads for each digital products. This can help you to easily find which digital product is more popular and getting more sales.
Track Video Playing: Videos are the best source to explain anything on your website to your visitor. It attracts visitors and provides useful knowledge practically. To find out which video getting more views and popularity, you need to track the clicks on a play button attached to each video.
How Event Tracking Works in Google Analytics
In event tracking, you have to add a code snippet to your website links to analyze the clicks on them. When the user clicks the links containing the code snippet, it gets tracked and the event gets added to Google Analytics.
There are 3 main components which you have to add to the code snippet as given below:-
- Category: It is the name to give to the object or element that you want to track.
- Action: It is the name of the type of event that the selected object performs such as click, downloads, video play, etc.
- Label: To summarize the event an object performs or add additional information about the object you want to track, you can use this field.
The above all are the attributes that help you to track the objects with Google Analytics.
How to Use Event Tracking with Google Analytics Easily in WordPress?
To track events on your WordPress website, you can use the below given two methods. In these two methods, the first one is fast and easy to use.
So, let’s get started.
Using MonsterInsights Custom Link Attribution Feature (Easiest Method)
MonsterInsights is the most trusted Google Analytics WordPress plugin trusted by more than 2 million websites. It’s the best option to easily track your website traffic to easily optimize your traffic for more conversions.
To use MonsterInsights for event tracking, you have to install the MonsterInsights plugin. After installation, you need to connect MonsterInsights with Google Analytics whose process you can find out on our MonsterInsights review post. The Custom link attribution feature is the new feature of MonsterInsights to create event tracking custom links.
Add the MonsterInsights custom event tracking attributes to the links you want to track. The attributes you have to add to the HTML links are given below:-
data-vars-ga-category
for event categorydata-vars-ga-action
for event action- and
data-vars-ga-label
for event label
Your HTML link will look like as given below:-
1 |
<a href="https://yoursite.com" data-vars-ga-category="Custom Category" data-vars-ga-action="Custom Action" data-vars-ga-label="Custom Label">Link</a> |
After you have done with adding the above attributes, MonsterInsights starts tracking your website links. You can check the reports under the WordPress dashboard menu option Insights >> Reports >> Publisher.
Let’s take an example of tracking the ‘Buy Now’ button on your website with URL https://example.com/pricing/. The button takes you to the pricing page where you can buy the product available with the website.
Add the MonsterInsights attributes to the ‘Buy Now’ link that content event category, action, and label as given below:-
1 |
<a href="https://yoursite.com/pricing/" data-vars-ga-category="Shoes" data-vars-ga-action="click" data-vars-ga-label="Pricing page buy now button">Buy Now</a> |
Now, every time when the user clicks on the above link, it gets tracked by MonsterInsights. The number of clicks to the button can be checked under the menu option Insights >> Reports >> Publisher. A page will open where you will get all the links clicked.
Using Onclick Attribute with Event Tracking Parameters
This method tracks the website links by adding the custom code to the links that you want to track. After you add the code snippet, each click gets tracked as an event in Google Analytics.
You have to add the onclick
attribute to the links with the parameters as given below:-
1 |
onclick = "_gaTracker('send', 'event', 'category', 'action', 'label', 'value')" |
Place the above code after the href
attribute of the anchor link. You have to replace the parameters send, event, category, action, label, and value with the value you want to assign.
A simple example of the URL containing the above parameters is given below:-
1 |
<a href="https://yoursite.com" onclick = "_gaTracker('send', 'event', 'shoes', 'click', 'Pricing page buy now button', '0')">Buy Now</a> |
The above example requires some knowledge of javascript to add to your website. You have to set up Google Analytics on your website manually to use this method.
Conclusion
You can use both the methods given above for event tracking with Google Analytics. However, the second method requires some javascript to add to your website which may be a difficult task if you are not a developer.
MonsterInsights makes it easier for you to easily connect with Google Analytics without any coding knowledge. After connecting your Google Analytics account with MonsterInsights on your website, you can easily create event tracking links using the above examples. You can also check the tracked clicks data under the reports section of MonsterInsights.