Introduction
Google Analytics can be an incredibly powerful tool, so let’s go over adding custom event scripts to your website. These can be used to track a wide variety of events, such as a user starting a video, downloading a pdf, or simply clicking a button. After the event tracking code is implemented, you will be able to see these events as part of your Google Analytics reports and get a better understanding of user activity on your website.
The Javascript
The Javascript used to send an event to Google is very simple:
1 | ga(‘send’, ‘event’, ‘Video’, ‘play’, ‘Fall Campaign’); |
Note: When using the Yoast SEO plugin for WordPress, the ‘ga’ variable has been changed to ‘__gaTracker’, so the javascript will be slightly different if you are using Yoast.
If you’re using the siteOrigin widgets plugin, it’s easy to create a button widget, then set this tracking code to run Onclick in the “Other attributes and SEO” pane. Now let’s take a closer look at the parameters.
The Parameters
The parameters have been defined by Google and are as follows:
[table id=1 /]
Now let’s see how labeling your data can give you a better understanding of how your website is being used.
Customizing your Data
Let’s break down these parameters:
‘send’ and ‘event’
These are required parameters, defining the action and type of action being committed.
‘eventCategory’
This parameter defines the type of object that was interacted with. This could be anything from ‘Video’ to ‘Button’ to ‘Sloth GIF’.
‘eventAction’
This parameter describes the type of action that occurred, such as ‘play’ or ‘click’.
‘eventLabel’
This parameter is how you categorize various segments of these events, such as ‘Fall Campaign’ or ‘Snowboarding Equipment’.
Google Analytics Reports
As users start triggering your events, you’ll be able to see this data in your Google Analytics reports. Go to the “Behavior” tab, then expand “Events” and click on “Overview”. This view shows you all events, including your new custom events; you can filter by category, action, or label.
Conclusion
That’s all it takes! With a little time spent on setup and labeling, you can customize your website to provide up-to-date information about user visit patterns, analyze goal progress and oversee campaign conversion rates.