• Basics
  • Setup
  • Events

How to Set Up Event Tracking in Monolytics: Full Walkthrough

Oct 22, 2024

Monolytics event tracking guide

This guide explains how to register events on your website. Events help you understand what happens on the site: product interactions, form submissions, sign-ins, purchases, and system-level actions.

Event names are case-sensitive. If you create two events that differ only by letter case, Monolytics will treat them as two separate events.

Before you begin

Make sure the Monolytics tracking code is already installed on your site. After that, you can choose one of two event-tracking approaches:

  1. Add event calls directly in your site code.
  2. Configure event forwarding in Google Tag Manager.

If you need help, write us at mykola@monolytics.app.

Track events directly in your site code

Once Monolytics is installed, you can call window.monolytics_send_conversion() anywhere in your frontend code. The example below sends an add_to_cart event.

if (window.monolytics_send_conversion) {
  window.monolytics_send_conversion("add_to_cart");
}

We recommend using the snake_case format for event names: lowercase words separated by underscores.

Examples of clear event names:

  • view_item for opening a product card
  • add_to_cart for adding a product to the cart
  • purchase for completing a checkout
  • sign_up for account registration
  • sign_in for account login
  • form_submit for sending a form

Set up events with Google Tag Manager

If your marketing and analytics scripts already live in Google Tag Manager, it usually makes sense to send Monolytics events from GTM as well. There are two ways to do it.


Use events that already exist in dataLayer

If your site already pushes events to dataLayer, you can forward the same event name to Monolytics through a Custom HTML tag.

  1. Open Tags in GTM and create a new tag.
  2. Select Custom HTML as the tag type.
  3. Paste the following code:
<script>
(function () {
  if (window.monolytics_send_conversion) {
    window.monolytics_send_conversion({{Event}});
  }
})();
</script>
  1. Attach the tag to the trigger for the event you already send to dataLayer, for example add_to_cart.
  2. Name the tag, save it, and publish the container.

Manually configure an event in GTM

If your site does not push events to dataLayer, you can still fire Monolytics events with a dedicated GTM tag and the right trigger.

  1. Create a new Custom HTML tag.
  2. Paste the following code and replace YOUR_EVENT_NAME with the real event name you want to track.
<script>
(function () {
  if (window.monolytics_send_conversion) {
    window.monolytics_send_conversion("YOUR_EVENT_NAME");
  }
})();
</script>
  1. Add the trigger that matches the user action you want to capture. For example, you can use a Click - Just Links trigger when a user clicks a specific outbound link.
  2. Save the tag and publish the GTM container.

Monolytics reports update in near real time, so you should see the first events within a few minutes after publishing.

That's all.

If you need any help, write us at mykola@monolytics.app.