Skip to main content

Creating custom events

GoodMetrics lets you track the specific actions that matter most on your website by creating custom events.

This can include things like purchases, button clicks, form submissions, or any other interaction you want to measure.

Add the event code to your website

To track an event, call the gmTrackEvent method anywhere on your site:

gmTrackEvent('event_name');

Replace 'event_name' with a descriptive name for the action you want to track.

Examples:

gmTrackEvent('Free Trial Signup');
gmTrackEvent('purchase');
gmTrackEvent('Booked Demo');

That's it — the event will start appearing in your GoodMetrics dashboard automatically.

Tracking values with events

You can also pass a numeric value with an event, which is useful for tracking things like revenue:

gmTrackEvent('Purchase', { value: 5000 });

The value field accepts integers only. Use cents to represent monetary values — for example, 5000 represents $50.00.

For more examples, see Tracking event values.

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.