You’re probably familiar with Google Analytics and you’ve been tracking your page views, bounce rates, sessions and other metrics regularly.

But, do you want to know how you could track user activity when they visit your website?

Event tracking provides you more in-depth insights to measure user interaction with elements on your website such as your CTA buttons.

In this article, we’ll show you how to add Google Analytics event tracking in WordPress.

What is Google Analytics Event Tracking?

Event tracking allows you to capture user interactions on your website. Most common interactions are clicking on a button, playing or pausing a video, submitting a form, and downloading files.

For example, if you have multiple newsletters sign up forms on your website, it could be down at the footer or on the sidebar. With event tracking, you could track which newsletter placement converts more.

Another example would be file download. If you give away freebies for your visitors, you could track how many people actually click to download the files and which type of content works best for your audience.

Tracking these events help you measure your conversion and plan your content strategy to boost user engagement and conversion on your website.

Adding Event Tracking Using Google Analytics

Make Sure You Use Universal Analytics Code

Before you start tracking events in Google Analytics, you need to make sure your website is using “Universal Analytics” tracking code or “Global Site Tag” tracking code.

If you’re using Universal Analytics, tracking script should look something like this:

Or if you’re using Global Site Tag (gtag.js) on your website, the script would look like this:

If your code looks different from above, replace the code with the new tracking code from Google Analytics.

Set up Goals in Google Analytics

Adding event tracking is simple but the event reporting provides a limited view and harder to measure conversion.

Setting up goals in Google Analytics is optional but recommended to do.

Goal reports let you measure activity and analyze conversion rates easily.

To set up the goal for your event, log in to your Google Analytics, and click on the gear icon on the bottom left screen to access the Admin page and click “Goals”.

Google Analytics - Admin Dashboard
Google Analytics – Admin Dashboard

Next, click on “+ New Goal” button to create a goal.

Google Analytics - New Goal
Google Analytics – New Goal

On the “Goal setup” step, choose “Custom” and click “Continue” button to go to the next step.

Google Analytics - Goal Setup
Google Analytics – Goal Setup

On the “Goal description” step, enter the name of your goal, and select “Event” as the goal type. Click the “Continue” button to proceed to the next step.

Google Analytics - Goal Description
Google Analytics – Goal Description

On the “Goal details” step, you need to specify the event condition to indicate successful conversion. Google Analytics will count it as a conversion only when all the conditions are matched.

Depending on the event you’re tracking, you can name the category, action, and label accordingly. If you’re not sure what’s the value you should enter, you could leave it as 0 in most cases.

Google Analytics - Goal Details
Google Analytics – Goal Details

Next, we add the code to send the event.

Add the onclick Attributes to the Element

Adding tracking code manually with the onClick method is the quickest and easiest way to add Google Analytics event tracking.

The onclick attributes will follow the format below for both Universal Analytics and Global Site Tag tracking codes

All you need to do is add the code above to the element you want to track and replace the “<category>”, “<action>”, “<label>” and “<value>” to match your event condition.

In this example, as I would like to track how many people submitted contact us form on my site. I need to edit the button on the form and add the code above.

It will look something like this.

That’s all for it. When users click on the link, it will send an event to Google Analytics which will appear on your goal report.

Adding Event Tracking Using Google Tag Manager

Google Tag Manager is another tool you could use to add tracking and custom codes to your website from a single dashboard.

The main benefit of using Google Tag Manager is you could multiple tags directly without manually making changes to your website code and you could manage it all from your dashboard.

If you set up Google Analytics on your website manually, you’ll have to remove it first and use Google Tag Manager to add Google Analytics code to your website.

For this example, I’ll show you how you could track outbound link click on your website.

Outbound link tracking is extremely useful as it could help you have better insights on your user’s behavior. You could measure how much traffic you’re sending to the affiliate websites.

First off, log in to your Google Tag Manager account and click “Triggers” and then click on the “New” button.

Add Event Tracking in WordPress
Tag Manager – Triggers

Enter any name for the trigger and click on “Trigger Configuration” and choose “Just Links” from the trigger type as we want to track link clicks.

Tag Manager - Trigger Type
Tag Manager – Trigger Type

Next, choose “Some Link Clicks” instead of “All Link Clicks” and update the conditions to fire the trigger.

Since we want to track outbound links — which are links on your website that take a user somewhere off your website, you need to make sure the link URL doesn’t contain your domain.

Tag Manager - Trigger Configuration
Tag Manager – Trigger Configuration

Don’t forget to update the domain with your own domain.

Next, we need to create a new tag. Tag is a snippet of code that will be added to your website.

Click on “Tags” and click on the “New” button.

Tag Manager - Tags
Tag Manager – Tags

Enter any name for your tag and click on “Tag Configuration” and choose “Google Analytics: Universal Analytics”.

Tag Manager - Tag Type
Tag Manager – Tag Type

Next, enter the “category” and “action” for the event.

For the label, you want to capture the actual link a user clicked on your site. Click on the “+” icon and choose “Click URL”.

“Click URL” is a variable provided by Google Tag Manager where Google will pass the actual URL to Google Analytics.

For “Google Analytics Settings”, you could pass the variable you created to store your Google Analytics ID. If you haven’t done so, click on the dropdown and choose “new variable”.

Tag Manager - Tag Configuration
Tag Manager – Tag Configuration

Next, choose the trigger you created earlier as the firing triggers.

Tag Manager - Tag Triggering
Tag Manager – Tag Triggering

Click “Save” and click “Submit” button to submit the tags.

Tag Manager - Submit
Tag Manager – Submit

Finally, enter the details for the changes and click “Publish” to push the changes to your site.

Tag Manager - Publish
Tag Manager – Publish

That’s it. Now you should be able to the event being tracked on your Google Analytics account.

Go to Realtime > Events and you should see the links click is tracked properly.

Add Google Analytics Event Tracking in WordPress
Google Analytics – Realtime Events

Adding Event Tracking Using MonsterInsights

This is probably the easiest way to add custom event tracking in WordPress.

If you followed my previous tutorial to add Google Analytics in WordPress with MonsterInsights, you could use MonsterInsights’ Custom Link Attribution feature.

With Custom Link Attribution, you could add custom event tracking attributes to any links you want to track with data attributes.

MonsterInsights provides data attributes you could use with the following format.

Similar to the Google Analytics method, you need to replace “<category>”, “<action>”, and “<label>” to match the event condition.

If you want to track outbound link, you have something like this.

That’s it. You could head over to Insights > Reports > Publisher and scroll down to view the Top Outbound Links report.

Final Thoughts

I hope by now you know how to add Google Analytics event tracking in your WordPress site.

Event tracking helps you understand your user activities when visiting your website and provider greater in-depth insights so you could plan your content marketing strategy better and optimize your website conversion and sales.

If you want to get actionable insights based on your visitors on your WordPress dashboard, you might want to check out our tutorial to add Google Analytics in WordPress.

Let us know which methods work best for you in the comment below.

If you found this article helpful, please do like and share the tweet below:

How to Add Google Analytics Event Tracking in WordPress?How to Add Google Analytics Event Tracking in WordPress?How to Add Google Analytics Event Tracking in WordPress?