Custom event tracking is an essential feature of any analytics tool, allowing you to gain deeper insights into user behavior on your website or application. Two prominent players in this field are Microsoft Clarity and Google Analytics. Both offer robust capabilities for tracking custom events, but they do so in slightly different ways. In this post, we’ll compare how to send custom events to both platforms and how to view them.

Sending Custom Events to Microsoft Clarity

Microsoft Clarity is known for its user-friendly interface and detailed session recordings. To send custom events, you use the clarity JavaScript function.

Code Tutorial:

  1. Set Up Clarity: Firstly, ensure that you have Clarity set up on your website. You should have a snippet of code provided by Clarity in your website’s head tag.
  2. Sending an Event: To track a custom event, use the clarity('track', ...) function. For instance, if you want to track when a user submits a form:
document.getElementById("myForm").addEventListener("submit", function() {
  clarity('track', 'Form Submission', { formId: 'myForm' });

Viewing Events in Clarity:

  • To view your custom events in Clarity, navigate to the dashboard.
  • Look for the “Custom Events” section. Here you’ll see a list of your tracked events.
  • Click on an event to view detailed information, including frequency and associated user sessions.

Sending Custom Events to Google Analytics

Google Analytics provides a comprehensive suite of tools for tracking all sorts of user interactions. The GA4 property allows for more flexible event tracking compared to Universal Analytics.

Code Tutorial:

  1. Set Up Google Analytics: Ensure that Google Analytics (GA4) is properly set up. Include the GA4 configuration snippet in your website.
  2. Sending an Event: With GA4, you can send a custom event using the gtag function. For example, to track the same form submission:
document.getElementById("myForm").addEventListener("submit", function() {
  gtag('event', 'Form Submission', {
    'event_category': 'Form',
    'event_label': 'myForm',
    'value': '1'

The gtag('event', ...) function sends the event to Google Analytics, where ‘Form Submission’ is the event name, and the object that follows describes the event.

Viewing Events in Google Analytics:

  • In Google Analytics, go to your GA4 property dashboard.
  • Navigate to “Events” under the “Engage” section.
  • Here, you’ll see a list of events, including your custom events.
  • Click on a custom event to view detailed data, such as event count, user engagement, and demographics.


Both Microsoft Clarity and Google Analytics offer powerful tools for tracking custom events, but they cater to slightly different needs and preferences. Clarity is particularly strong in visualizing user interactions through session replays and heatmaps, while Google Analytics provides extensive data analysis tools. By integrating custom event tracking into your analytics strategy, you gain valuable insights that help in making informed decisions to enhance user experience and engagement on your site.

Remember, the key to effective use of these tools lies in carefully planning your event tracking strategy to ensure the data you collect is both meaningful and actionable. Happy tracking!

By Tech Thompson

Tech Thompson is a software blogger and developer with over 10 years of experience in the tech industry. He has worked on a wide range of software projects for Fortune 500 companies and startups alike, and has gained a reputation as a leading expert in software development and design.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WordPress Appliance - Powered by TurnKey Linux