Overview
After the GhostlyX script loads, the globalghostlyx() function is available in the browser. Use it to track custom events, fire manual pageviews, and manage visitor opt-out preferences.
Track a custom event
Track a custom event with properties
Track a manual pageview (SPAs)
For single-page applications where you manage routing manually and are not usingdata-spa="auto":
Track a manual pageview with a custom URL
Opt a visitor out
Stores an opt-out preference in the visitor’s localStorage. While opted out, no data is sent to GhostlyX for that visitor.Opt a visitor back in
Check opt-out status
Returnstrue if the current visitor is opted out, false otherwise.
Self-exclusion
To exclude your own visits while developing or testing, callghostlyx('opt-out') in your browser console. This stores a preference in localStorage and no data will be sent from that browser until you call ghostlyx('opt-in').