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.

commit 7f343b7 · authored · 1 min read

Event tracking with Google Analytics

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,

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

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

Example usage follows,

<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.

local graph · open full graph

"Event tracking with Google Analytics" is connected to the topics Analytics, Search Engine Optimization and related to 5 other entries. Microsoft Clarity - Setting Up with GatsbyJS & First Impressions Microsoft Clarity - Setting… Redirect HTTPS requests to HTTP using IIS Rewrite rule in Web.Config Redirect HTTPS requests to … Redirect HTTP to HTTPS using Web.Config in IIS Redirect HTTP to HTTPS usin… Redirect WWW to Non-WWW using Web.Config in IIS Redirect WWW to Non-WWW usi… Redirect non-www urls to www urls Redirect non-www urls to ww… Analytics #analytics Search Engine Optimization #seo Event tracking with Google Analyt…

comments

loading discussion…