Want to track clicks on your most important links and call-to-action buttons? You’re in luck! You can track these kinds of clicks using custom events in Google Analytics.
However, the custom event setup process is a bit tricky for beginners. That’s where the MonsterInsights custom events tracking feature comes in handy.
In this article, we’ll show you how to set up Google Analytics custom events in WordPress the easiest way: With MonsterInsights.
What are Google Analytics Events?
Google Analytics events are a way to track clicks on parts of your website like links, buttons, and videos. This allows you to see how your site visitors are interacting with your site content, and helps you measure conversions.
Once you’re tracking the right clicks, you can update or rearrange any content that’s not getting as many clicks as you hoped to make it work better for you.
For example, let’s say you added a Buy Now button in your sidebar, and now want to know if users are clicking on it. Custom event tracking allows you to track that!
A Google Analytics event has 3 main parameters that you choose in order to track it.
- Event Category: Typically the name of what your users click, like “CTA” for call-to-action buttons
- Event Action: Typically the type of interaction, like “Click” for clicking on the buttons
- Event Label: Additional information about the event you want to track, like “Buy Button” in this case
So if you want to set up event tracking for a button click, your parameters might be something like this:
- Category: “CTA”
- Action: “Click”
- Label: “Buy Button”
Once it’s set up, Google Analytics records the clicks on your call-to-action button as custom events with the above parameters, which you’ll see in Google Analytics reports.
Now, let’s go deeper into how to set up WordPress event tracking.
Google Analytics Event Tracking Video Tutorial
Check out our video tutorial or you can read the written steps below.
Setting Up Google Analytics Custom Event Tracking in WordPress
Since Google Analytics doesn’t track events on its own, you’ll have to set up your event for each button or link on your site that you want to track.
MonsterInsights Google Analytics plugin simplifies the whole event tracking process, making it take only a few minutes to set up. Anyone can do it, even those without coding knowledge.
Adding Custom Link Tracking with MonsterInsights
MonsterInsights is the best WordPress Google Analytics plugin on the market. It helps you use Google Analytics with WordPress in the simplest way possible.
MonsterInsights has a Custom Link Attribution feature to allow you easily add custom event tracking to your links and buttons. You’ll just add a short snippet of HTML to your links (don’t worry, we’ll walk you through it!) to see how many clicks they’re getting.
To start, let’s take a look at this little bit of HTML code. Yes it’s code, but don’t let it scare you away! This is what you’ll need to add to your links in WordPress in order to track them with MonsterInsights:
<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>
Let’s go back to our Buy Now button example. To set up event tracking on that button, we’d make these changes to the above code:
- Put the link for our button in where it currently says “https://www.example.com”. So, your link might be something like “https://www.yoursite.com/pricing”.
- Change “Custom Category” to “CTA”
- Change “Custom Action” to “click”
- Change “Custom Label” to “buy button”
Note: Keep the quotation marks in your code!
Now, our code looks like this:
<a href="https://www.yoursite.com/pricing" data-vars-ga-category="CTA" data-vars-ga-action="click" data-vars-ga-label="buy button">Buy Now</a>
Fairly simple, right? Where you still see the words “Buy Now,” that’s the anchor text for your link (as in the text that you’ll see hyperlinked on your site). In our example, we’re not using text, though. We’re using an image.
Since the button is in the sidebar in our example, that means it’s in a widget. In order to use our event tracking code, we’ll have to put the image into a Custom HTML widget.
Here’s how to do that.
First, head to your media library and grab the URL of your button image.
Let’s say your image link is https://www.yoursite.com/wp-content/uploads/2021/05/buy-now-button.png, and you want to link that image to https://www.yoursite.com/pricing with event tracking.
Here’s what your HTML code looks like now:
<a href="https://www.yoursite.com/pricing" data-vars-ga-category="CTA" data-vars-ga-action="click" data-vars-ga-label="buy button"><img src="https://www.yoursite.com/wp-content/uploads/2021/05/buy-now-button.png" alt="buy now button"></a>
You can copy paste the code above and just input your own links and event parameters. Paste it right into your Custom HTML widget, save it, and check to make sure it looks correct and leads to the right page on your site.
Here’s what ours looks like:
That’s it! Now, MonsterInsights will track your button clicks.
To recap, here are the steps we took at add event tracking code to a button image in our sidebar:
- We chose three parameters that are meaningful for us: Category (CTA), Action (click), and Label (buy button)
- We wrote out our code using those three parameters and added our link (https://www.yoursite.com/pricing)
- We uploaded our image to the media gallery and copy pasted the URL into our code
- We copied our full code into a Custom HTML widget
- We viewed our site and clicked the link to make sure it works.
Once you add the tags, MonsterInsights will send the link click data to Google Analytics for you to use in your reports.
We hope this article helped you to learn how to set up Google Analytics custom event tracking in WordPress.
You might also want to check out our guide on How to Track All Link Clicks in Google Analytics (Step by Step).