analytics | seo

Event tracking with Google Analytics

by Abhith RajanAugust 17, 2017 · 2 min read · Last Updated:
Share this

I hope you have already added google analytics tracking script in your master page. If not see the page source of this page and check at the bottom of the page, there you can see some script which is provided by google analytics when we add a website (property) to our account in Google analytics which will track the page views etc for the whole website.

To add event tracking, we need to trigger the following function,

1ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

In which,[eventCategory] and [eventAction] are required fields.

Example usage follows,

1<a href="tel:1800123456" onclick="ga('send', 'event', 'Phone Call', 'Click/Touch', 'Contact Page');">1800123456</a>

The above code will track user interaction with the phone number. As you can see, here the eventCategory is “Phone Call”, and eventAction is “Click/Touch”. We can use the eventLabel field to improve the metrics by like here is assigned with value “Contact Page” so that we knows how much triggered from that page itself. And for other pages, we can have different eventLabel.

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub

Abhith Rajan

Written by Abhith Rajan Buy me a coffee
Abhith Rajan is an aspiring software engineer with more than 6 years of experience and proven successful track record of delivering technology-based products and services.

Related Services




Check and improve how search engines and social media websites see and display your website.