How to Use Event Tracking for WordPress

A Complete Guide to Using Google Analytics Event Tracking in WordPress

You’re probably already using Google Analytics to track all kinds of traffic-related metrics like page views, bounce rates, and average session duration. What if you could kick things up a notch and track how your visitors interact with on-page elements like buttons, forms, and embedded videos?

Google Analytics enables you to configure event tracking functionality on your WordPress website to get more insight into user behavior. It answers questions like Does the Buy Now! button get clicked more when it’s placed in the center of the landing page or at the end? and Are my visitors having difficulty filling out the checkout form?

Analyzing these measurable events puts you in a better position to evaluate user interaction and work toward improving your marketing strategy. In this post, we’ll show you how you can get started with Google Analytics event tracking in WordPress – in four easy steps.

Let’s put everything into context before we begin.

How Can I Use Google Analytics Event Tracking?

If you want your website to be successful, then you’ll need to track elements that govern your website’s success. For instance, if your goal is to increase sales, you’ll need to track the primary Buy Now! button to gain insight into how prospective customers are interacting with it.

Event tracking allows you to understand your visitors better and improve your marketing efforts based on their behavior. Simply put, when you understand exactly what it is that makes your website successful, you can figure out how to be even more successful. And in the case of Google Analytics event tracking, it’s about optimizing your page elements, marketing strategies, and element placement to resonate with your viewership.

Google Analytics event tracking allows you to track your visitor’s intent and how many times they perform a particular action. Say you have a web page with a product video, a Buy Now! button, and a product rating system. In this scenario, you could track how many users performed the following events:

  • Clicked the Play button on the video.
  • Clicked the Buy Now! button.
  • Rated the product using the five-star rating system.

Now that we have a pretty good idea about what Google Analytics event tracking is, let’s delve deeper and take a look at how you can get started with event tracking in WordPress.

How to Use Google Analytics Event Tracking in WordPress

Google Analytics event tracking allows you to track user actions on your WordPress website – even if the user doesn’t redirect to a new page – by associating some JavaScript code with the page elements you want to track. In this section, we’ll walk you through a quick and easy tutorial to get started with event tracking in WordPress.

Step 1: Some Preliminary Steps

Before you begin, you’ll need to make sure your Google Analytics account is configured properly. If you don’t already have an account set up then you’ll need to install Google Analytics on your WordPress website first. And those of you who are already using Google Analytics to track traffic-related metrics need to make sure you’re using the upgraded Universal Analytics code.
Website Tracking code

If you’re not sure which code you’re using, log into your Google Analytics account and navigate to Admin > Tracking Info from the dashboard. The code snippet under the Website Tracking section should look something like this:

https://gist.github.com/mariaansari/66380c120389f6048dc8c0667c745bba

However, if it doesn’t look like this then chances are you’re still using the older version of the code. All you have to do is replace the old code snippet with the new one by updating your WordPress website’s property settings from your Google Analytics account.

Once you have your Google Analytics account properly configured, you can move on to creating events to track.

Step 2: Create an Event to Track

The next step is to analyze your web page and decide which event(s) you’d like to track. For the purpose of this tutorial, we’ll show you how to set up event tracking for a simple Register button.

Register button

To get started, log into your Google Analytics account and navigate to Admin > Goals from the dashboard.

View > Goals

Next, click on the New Goal button to begin setting up the goal you’re going to track.

New Goal button

You’ll be redirected to a new screen prompting you to fill out a three-step form. In the first step, Goal setup, select the Custom option and click the Continue button to proceed.

Goal Setup

In the second step, Goal description, you’ll need to enter a name for your goal so that you can keep track of it later on. We’ll name our goal Number of Registrations. Next, you’ll need to select the goal type Event. Once that’s done, click the Continue button to move on to the final step.

Goal Description

In the final step, Goal details, specify the conditions for a successful conversion. This means that whenever all of the conditions are met, Google Analytics will count it as a conversion. You can set the event conditions for your goal however you’d like. We’ve configured ours as follows:

Goal Details

Once you’ve completed all three steps, click on the Save button at the bottom of the screen to activate your goal. So far, we’ve created an event to track in Google Analytics, and in the next step, we’ll show you how to begin tracking this event on your WordPress website and send its data directly to Google Analytics.

Step 3: Event Tracking

There are two different ways you can begin tracking the events you created in Google Analytics – doing it manually and by using the Google Tag Manager. Let’s explore both methods one at a time.

Event Tracking With Manual Code

In order to begin tracking events manually using code, you’ll need to leverage the onClick code method. It’s the quickest (and easiest) way to get started with event tracking. The key idea behind this is that you add some code to the link you want to track and every time a user clicks on the link, its event conditions are sent to Google Analytics.

To get started, we’ll use the onClick parameter (with the following format) to track user interaction with the element we’re monitoring.

https://gist.github.com/mariaansari/e88c625097e299d64fcb806a5a1f2364

Following our running example, here’s what the link behind the Register button looks like:

https://gist.github.com/mariaansari/e251ae8d6a02ee806e28135141a41375

That’s all there is to it! Now, every time someone fills out the registration form successfully and clicks the Register button, its event conditions will be sent to Google Analytics.

Event Tracking With Google Tag Manager

Another way to begin tracking events is by using the Google Tag Manager. The key advantage of using this method is that you can manage all of your events from a single platform and you don’t have to mess around with code.

Once you have Google Tag Manager all set up and linked to both your Google Analytics account and WordPress website, you can begin tracking events. Here’s how:

Start off by logging into your Google Tag Manager account and navigating to Triggers. From the Triggers screen, click on the New button to add a new trigger.

Triggers screen

The trigger configuration window will slide in from the right side of the page, prompting you to choose your trigger type. Based on the event you’re trying to track, choose an appropriate trigger type. Since we’re tracking our Register event, we’ll click the Form Submission option.

Choose trigger type

Next, in the Trigger Configuration screen, make sure both the Wait for Tags and Check Validation options are unchecked. In addition to this, configure the This trigger fires on option to fire on All Forms.

Form Submission screen

Once you’re done with that, click the Save button to continue. Next, head over to Tags from your Google Tag Manager dashboard and click the New button to create a new tag.

New tag

The tag creation window will slide in from the right side of the page. Begin the configuration and select Universal Analytics as your Tag type. Next, set the Track Type to Event and enter the values for the Event Tracking Parameters in their corresponding fields.

Register Event Tag

Finally, check the Enable overriding settings in this tag option and enter your Google Analytics Tracking ID into the input field. If you’re not sure what your tracking ID is, you can log into your Google Analytics account and copy/paste it from there.

Choose trigger

 

Now, scroll down to the Triggering section and choose the trigger you created before from the list of available triggers.

Triggering section

Once that’s done, click the Save button at the top-right corner of the screen. Next, click the Submit button and give your tag a Version Name and Version Description. And once that’s all set, click the Publish button to proceed.

Publish

And that’s it! You’ve successfully created and linked a tag from the Google Tag Manager to your Google Analytics account to track the event on your WordPress website. Now, all that’s left to do is view the event tracking reports generated by Google Analytics.

Step 4: View Event Tracking Reports

To view the event tracking reports, log into your Google Analytics account and navigate to Real-Time > Events. It should look something like this:

Google Analytics Real-Time reports

Your event(s) will immediately begin being tracked and you can view the reports in realtime from your Google Analytics account.

Conclusion

Google Analytics event tracking brings powerful functionality to the table. It allows you to better understand how your site’s visitors are interacting with your web pages and what you can do to optimize those interactions in your favor.

Let’s quickly recap the main steps you need to take to get started with event tracking in WordPress:

  1. Start off by making sure you have a Google Analytics account and that you’re using Universal Analytics code.
  2. Create an event that you’d like to track through the Google Analytics platform.
  3. Implement event tracking either through manual code or by using the Google Tag Manager.
  4. Finally, view the event tracking reports and learn more about how users interact with your web page elements.

Are you thinking about implementing Google Analytics event tracking on your WordPress website? Let us know by commenting below!

This post may contain affiliate links, which means Nimbus Themes may receive compensation if you make a purchase using these links.

Written exclusively for

Nimbus Themes Publishing Logo

About the Author

From C++ to PHP, the language Maria thinks in is code, and translates it to English for humans to understand. She has a degree in Computer Science and is the writer of choice for many organizations. She is also The Big Boss at BloggInc, calling all the shots and personally supervising every word and piece of content. In her spare time you can find her playing GTA V, lounging at the farm, or trying to beat her husband at indoor badminton.

Read all posts

Leave a Reply

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