
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:
- Add event calls directly in your site code.
- 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_itemfor opening a product cardadd_to_cartfor adding a product to the cartpurchasefor completing a checkoutsign_upfor account registrationsign_infor account loginform_submitfor 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.
- Open Tags in GTM and create a new tag.
- Select Custom HTML as the tag type.
- Paste the following code:
<script>
(function () {
if (window.monolytics_send_conversion) {
window.monolytics_send_conversion({{Event}});
}
})();
</script>
- Attach the tag to the trigger for the event you already send to
dataLayer, for exampleadd_to_cart. - 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.
- Create a new Custom HTML tag.
- Paste the following code and replace
YOUR_EVENT_NAMEwith the real event name you want to track.
<script>
(function () {
if (window.monolytics_send_conversion) {
window.monolytics_send_conversion("YOUR_EVENT_NAME");
}
})();
</script>
- 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.
- 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.