analytics | seo

Event tracking with Google Analytics

When you want to get metrics related to user interactions on various parts of your website Google Analytics (ga)  event tracking can be helpful and is easy to integrate as well.

Abhith Rajan
Abhith RajanAugust 17, 2017 · 1 min read · Last Updated:

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,


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

Example usage follows,

  onclick="ga('send', 'event', 'Phone Call', 'Click/Touch', 'Contact Page');"

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 byAbhith Rajan
Abhith Rajan is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes 🧑‍💻, write ✍️, learn 📖 and advocate 👍.

Is this page helpful?

Related ArticlesView All

Related VideosView All

GatsbyJS & Analytics: How to Add Google Analytics 4.0 To a Gatsby Site Using Gtag

Related Tools & ServicesView All

Meta Tags — Preview, Edit and Generate

With Meta Tags you can edit and experiment with your content then preview how your webpage will look on Google, Facebook, Twitter and more!

Robots.txt generator - Create a robots.txt file instantly

Generate a robots.txt file for free with this easy-to-use tool. Make sure search engine crawlers are crawling and indexing your site.