How to Add Google Analytics Event Tracking in WordPress?

How to Add Google Analytics Event Tracking in WordPress?

Have you ever desired to track user activity when they are on your WordPress website? By installing Google Analytics, you can track pageviews, referral sources, time spent on page and more, but for a more intense insight, you have to use Event Tracking. Here, in this article, we will illustrate you How to add Google Analytics Event Tracking in WordPress.

What is Event Tracking in Google Analytics?

The Event Tracking allows you to measure user interaction on your site. These interactions can be things such as playing videos, submitting forms, clicking on a button, downloading files, etc.

Let’s say you’ve added a video to your product page, and now want to know how effective it is for your conversions. However, the Event tracking permits you to track how many users play videos, so that you can decide for yourself.

One more example is based form submission. If you are using a gravity form or any other contact form plugin, the result of form submissions is not a new pageview.

By Using Event Tracking, you can see how users interacted with the form. This is also for downloading a file on a page. You can track how many users download the file by using track tracking and which button was clicked on the page.

The Event tracking is different from tracking links in Google Analytics. Also, you can track links in WordPress by using Google Analytics by adding UTM source to the link.

Furthermore, these scalable actions permit you to see how users behave on your website. Then you can change your strategy to add content that creates more user engagement and interaction. After all, this means more sales and conversions on your site.

There are some users activities examples that can be tracked in google analytics:

  • Loading of Ajax, JavaScript or flash contents.
  • Downloading a file.
  • Loading of a dynamically generated webpage.
  • Clicking on an image.
  • Loading of light boxes.
  • Loading of a video on a webpage.
  • Viewing video footage of certain length.
  • Viewing a video.
  • Interaction with a gadget.
  • Clicking on an internal link.
  • Clicking on a video’s pause/play/stop button.
  • Desertion of a form field.
  • Loading of pop-ups.
  • Movement of a mouse.
  • Clicking on a button.

Types of Events in WordPress

A user can connect with a web page element through keyboard, mouse, frame or form. Thereupon we can have:

Keyboard Events:- Interaction of user with a keyboard.
Mouse Events:- Interaction of user with a mouse.
Frame Events:- Interaction of user with a frame/iframe.
Form Events:- Interaction of user with a form embedded on a web page.

When the google events occur, they can or cannot generate pageviews.
Therefore, we have the two categories of events:

When the events occur, they generate pageviews: This event is like clicking on an internal link on a webpage.
When the events occur, they do not generate pageviews: This event is like as clicking on an external link, loading of Ajax/Flash content, viewing of a video, downloading a file, scrolling a webpage etc.

Note: By default Google analytics cannot track such events that do not generate pageviews when it occurs such as: clicking on an external link, viewing of a video, Downloading a file, etc.

However, the user can track these events only via event tracking or virtual pageviews.

Structure of Google Analytics Events

1. Event Category:- Event category is the name that appiont to the group of same events that you want to track. For example, reading, Youtube videos, profitable engagement, etc.

GOOGLE ANALYTICS EVENT TRACKING
2. Event Action:- Event action is the name that assigned to the type of event that you want to track for a specific webpage element. For example- Play, Pause, etc.

google analytics event tracking

3. Event Label: Event label is assigned to the web page element whose interaction of users you want to track. For example- Title tag of a webpage, title of a video, name of downloadable file, name of gadget, etc.

google analutics event tracking tracking
4. Event Value: Event value is the numerical value assigned to the event you want to track. For example- Event time, length of the video footage played or some monetary value.

google analytics event tracking

5. Non Interaction: Non interaction is used to assigned an event as interactive or non-interactive. This field object can have true or false value. Note that, the default value is always false means by default an event is considered as interactive and it affects the bounce rate calculation.

However, if you want to create non-interactive event, it does not affect on the bounce rate calculations.

Note: There are no fast rules for what type of data you put into ‘event category’, ‘event action’, ‘event label’, unless you are specifying the value of the type of text to ‘event category’, ‘event action’, and ‘event label’, and value of type integer to ‘event label’.

Getting Started

Before you start, you will need to setup and install Google Analytics on your WordPress site. If you have any problem, read our guide on How to Add Google Analytics to WordPress.

Upgrade to Universal Analytics Code

Now, at present there are two types of Google Analytics implemented on sites. However, Google is slowly pressing the old code by asking webmasters to use the newer ‘universal Analytics code’.

If your Google Analytics code looks like this:

<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);ga(‘create’, ‘UA-XXXXXX-1’, ‘auto’);
ga(‘send’, ‘pageview’);</script>

Then you are already using the new Universal Analytics code. No action is necessary, and you can move on to the next step.

However, if your code does not look like this, then you might be using the old Google Analytics code. You have to upgrade, Google has a detailed upgrade guide for that.

In fact, if you are not using advanced tracking features in Google Analytics, you can replace the old code with the new from your account’s property settings.

Creating your Event in Google Analytics

The very first, you have to create your event in your Google Analytics account. To do this, you have to log in to your Analytics dashboard and click the Admin link at the top.

If you have many sites under your Analytics account, make sure that you are viewing the dashboard for the site where you want to add the event.

Add Google Analytics Event Tracking in WordPress

There are three columns below the Admin page. Click the ‘Goals’ link below the ‘View’ column.

Add Google Analytics Event Tracking in WordPress

Thereafter, click the new goal button to create a goal. With the goal setup options, you need to choose a custom option and then click the next button to continue.

Add Google Analytics Event Tracking in WordPress

It will bring you in the goal description step. You need to provide a title for your custom goal, it’s something that will help you identify the goal within Google Analytics.

Under the goal type, you have to choose the event. Thereafter click the next step button to continue.

Add Google Analytics Event Tracking in WordPress

The final step is to provide goal details. You must enter the event condition here.

Analytics will count the conversion if all these conditions match.

Here, in this example, we have provided a category and action for the event. We entered a label for the event and provided a value. Depending on what type of event you are trying to make, you can give the names of your own categories, actions, and label.

If you think your event should pass on the value that can be calculated, then you can enter that value here. However, using the value of 0, the most common event works well for tracking too.

Add Google Analytics Event Tracking in WordPress

Lastly, click the create goal button to save and activate the goal. Now, successfully you have enabled tracking for an event in Google Analytics. The next step is to track this event on your site and send data to Google Analytics.

Adding Google Analytics Event Tracking onClick

The fastest and easiest way to add Google Analytics event tracking is by using the onclick method. When a user clicks on an element, this method only sends the event conditions to Google Analytics.

Here, in this example, we are tracking users who click on the eBook download link.

We will add the onClick parameter to the download link by using this format.

onClick=”ga(‘send’, ‘event’, ‘label’, ‘category’, ‘action’, ‘value’);”

You will have to replace the action, label, category, and value with the conditions of your event. At the end your download link will look like this:

<a onClick=”ga(‘send’, ‘event’, ‘Downloads’, ‘Click’, ‘Ebook downloaded’, ‘0’);” href=”http://example.com/wp-content/uploads/2015/06/free-ebook.pdf”>Download Free Ebook</a>

That’s all!

When users click on this link, it will send an event to Google Analytics that will be visible in your site’s reporting.

Adding Event Tracking Using Google Tag Manager

Google Tag Manager is an online tool that permits you to add different tracking code as tags below a dashboard.

Also, you can use it to create tags to track events in your Google Analytics account. The main advantage of using Google Tag Manager is that you will not have to enter the code manually on your site, and you can manage all your tags from one location.

If you have already added the Google Analytics tracking code manually to your site, you will need to remove it.

After successfully added the Google Analytics tag to Tag Manager, the next step is to create a new trigger. For this tutorial, we will track a contact form submission as an event.

In Tag Manager, click on the trigger and then click the New button.

Add Google Analytics Event Tracking in WordPress

It will bring you into the trigger creation wizard. This is where you would select the event select form.

Add Google Analytics Event Tracking in WordPress

However, you need to uncheck the waiting for the tag and check the verification options under the configure trigger section. After this, click the Continue button to move to the next step.

Add Google Analytics Event Tracking in WordPress

In the next step, you have to select when to fire the trigger. If you have only one form on your page, you can select all the forms. If your page has more than one form, then you click on some forms button.

Add Google Analytics Event Tracking in WordPress

Furthermore, if your page has more than one form and you wish to track a specific form, then you have to tell Google Tag Manager what form you want to track. When you click on some form buttons, you will see the filters.

Add Google Analytics Event Tracking in WordPress

However, a filter is a set of instructions such as if A matches B, then fire the trigger. You need to choose new variable.

Although, choosing new variable will bring a pop up a popup where you can create your own variable. Select the DOM element as your variable type. Thereafter, select the ID as your selection method under the configure variable.

Now you have to find your form’s ID. Go to the form page on your WordPress site, move the mouse to the first form field and choose Inspect Element.

Your browser screen will split up into two. Thereupon, you will see the HTML for your page in the screen below. The ID attribute will either be part of the <form> tag or the div including the form.

Add Google Analytics Event Tracking in WordPress

Under the element ID and attribute copy and paste the form ID. Thereafter, click the Create Variables button.

You will return to the fire on the filter, where you can now choose your custom variable. Select ‘Contains’ in the matching rule and then re-enter your form’s ID.

Now click the create trigger button to continue.

The next step is to create a tag for the event that we want to track. In Google Tag Manager, click the Tags and then click the New button.

However, it will bring you to the tag creation wizard. Choose Google Analytics as your product and then click the Continue button.

Add Google Analytics Event Tracking in WordPress

Now you have to select Universal Analytics as your tag type. You will be asked to provide your Google Analytics tracking ID. You can get it from your Google Analytics account.

Under track type, you have to choose an event and then provide the category, label, value information, and action. In this example, we used forms for the category, contact forms as a label, forms submission for action, and submitted as the value.

Click the continue button to go to the next step. This is where you choose to fire the tag. Click on the More button and choose the trigger that you created earlier.

Add Google Analytics Event Tracking in WordPress

Lastly, click the create tag button to save your tag.

Remember that saving the tag does not make it go live on your website. You will still have to click the publish button to make it live.

Add Google Analytics Event Tracking in WordPress

That’s all!

Now you can go to your site and submit the form. Go to Real Time>>Events in your Analytics account and you will see your event tracked and recorded.

Add Google Analytics Event Tracking in WordPress

By using Tag Manager, you can create different types of events and manage them with Google Tag Manager. Also, this prevents you from editing your WordPress theme or manually adding tracking code.

CONCLUSION

Here, we have discussed How to add Google Analytics Event Tracking in WordPress? Often, we concluded What is Event Tracking in Google Analytics and types of Google Analytics Events?

We hope this blog helps you to add Google analytics events. Thus, if you have any hurdle with adding the same, let me know in the comment section provided below.

If you liked this post then share it with your peers.

If you still need help contact  our WordPress Technical Support Team. Please Dial + 1 844 897 0441 (Toll-Free). We  have a team of good professional who can resolve all your issues related to WordPress.

Read More Blogs:



Leave a Reply