Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ghostlyx.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

After the GhostlyX script loads, the global ghostlyx() 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

ghostlyx('event', 'Event Name')

Track a custom event with properties

ghostlyx('event', 'Purchase', { revenue: 49.99, plan: 'pro' })
Properties must be strings or numbers. A maximum of 20 properties are supported per event.

Track a manual pageview (SPAs)

For single-page applications where you manage routing manually and are not using data-spa="auto":
ghostlyx('pageview')

Track a manual pageview with a custom URL

ghostlyx('pageview', { url: '/virtual/page' })
Use this to track virtual pages or to override the URL that GhostlyX records for the current view.

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.
ghostlyx('opt-out')

Opt a visitor back in

ghostlyx('opt-in')

Check opt-out status

Returns true if the current visitor is opted out, false otherwise.
ghostlyx('is-opted-out')

Self-exclusion

To exclude your own visits while developing or testing, call ghostlyx('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').