Learn how to create custom events in GoodMetrics so you can track the user actions that matter most to your business.
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
Section titled “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('Started Trial');gmTrackEvent('purchase');gmTrackEvent('booked_demo');That’s it — the event will start appearing in your GoodMetrics dashboard automatically.
Tracking values with events
Section titled “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.
Tracking properties with events
Section titled “Tracking properties with events”You can also pass a property to add context to an event, such as a destination URL or a plan name. This lets you use a single event and break it down by each property value:
gmTrackEvent('Purchase', { property: 'team' });This way, a single event can cover many variations instead of needing a separate event for each one. For more examples, see Tracking event properties.
Domain validation and spam prevention
Section titled “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.