Skip to main content

Creating Custom Events

GoodMetrics lets you track the specific actions that matter most to your business by creating custom events. To set up an event, you’ll first create and name it inside your GoodMetrics account, then add the tracking code to your website.

Step 1: Create Your Event in GoodMetrics

Before adding event code to your site, you’ll need to create the event in your GoodMetrics dashboard:

  1. Navigate to your Site Settings page.
  2. Click Manage Events.
  3. Enter a name for your event.

Naming rules:

  • Event names must be lowercase letters only.
  • Use underscores instead of spaces.
  • Example: free_trial

Step 2: Add the Event Code to Your Website

Once your event has been created in GoodMetrics, you can trigger it on your site using the gmTrackEvent method.

Basic Event Tracking

Use the following syntax to track a simple event:

gmTrackEvent('event_name');

Replace 'event_name' with the event name you defined in your dashboard.

Example: gmTrackEvent('free_trial');

Event Tracking with a Value

You can also pass a value with an event. For example, revenue from a purchase:

gmTrackEvent('purchase', { val: 5000 });

In this example, the event tracks a purchase worth $50.00.

Note:

  • Only integers are accepted for the val field.
  • Use cents to represent monetary values. (e.g., 5000 = $50.00).

Domain Validation and Spam Prevention

To protect data integrity, GoodMetrics verifies that all event triggers originate from your registered domain.

If an event fires from an unverified domain, it will be blocked.

💡 Make sure your event code is always executed on your own domain to avoid missed events and ensure accurate reporting.