Skip to main content

Firing a custom event

Call the global ghostlyx() function after the tracking script has loaded:
The event name is a free-form string. Choose names that are meaningful to your team. Event names are case-sensitive.

Adding properties

Pass an object as the third argument to attach properties to the event:
Properties must be strings or numbers. A maximum of 20 properties are supported per event. Properties appear in the goal detail view in the dashboard once a matching goal is created.

Connecting events to goals

Events are only counted in the dashboard when a matching Custom event goal exists. Create a goal with the same event name in Settings > Goals to start seeing completions and conversion rates.

SPA and deferred loading

If your script loads asynchronously, wrap event calls in a check to avoid errors before the script is ready:

Server-side events

If you need to fire an event from your server (for example, after a payment is confirmed server-side), use the Events API instead of the JavaScript API. See Server-side tracking for details.