Method Calls

trackEvent

trackEvent Method


The trackEvent method and API events that you create in Event Builder provide a way to indicate that something important has happened on your site. This method can be called multiple times per page. However, Monetate only collects data once per event per page. For example, you can track when a customer's mouse pointer hovers over a navigation item by reporting a nav_hover event each time this occurs. Nevertheless, the Monetate platform only tracks the first instance on each page.

Monetate Inspector View

The Monetate Inspector browser plug-in doesn't show custom events that you push with the trackEvent method unless you first create an API event in Event Builder. See Create API Events in the Monetate Knowledge Base for the steps to create this type of event.

The Events panel of Monetate Inspector, with a trackAPI event in the 'Page Event' row


Code Sample

Once you create the API event in Event Builder with the appropriate event key, the code snippet below explains how to trigger the event.

An event key is a string composed of alphanumeric characters (a–z, 0–9) and select special characters (spaces, underscores, and hyphens). Ensure that you give an event key a descriptive name so that you can easily understand what it references in the code.

You can make these calls from anywhere in your site's code to signify when a custom event has occurred.

This code sample shows a typical call to track an event. It contains the method in use that results in the Monetate Inspector results shown in the previous screenshot.

trackEvent Example