Ghost ID Docs
Product documentation
Back to Dashboard

Ghost Pixel Installation

Install the Ghost Pixel once, place it in your site template, and it will begin capturing visits automatically.

๐Ÿš€ Basic Installation

Add the Ghost Pixel script tag with your `data-site-id`.

HTML
<script defer src="https://analytics.ghostid.ai/api/script.js" data-site-id="YOUR_SITE_ID"></script>

Place it in the `<head>` of your site whenever possible.

The `defer` attribute ensures the Ghost Pixel loads without blocking the page.

โš™๏ธ Configuration Options

AttributeDefaultDescription
data-site-idrequiredYour Ghost ID site identifier
data-namespaceghost-idCustom namespace for multi-instance setups

๐Ÿงฉ JavaScript API

Use these methods to attach identity and custom actions to the current visitor session.

GHOST.identify(email, traits)

JavaScript
GHOST.identify("user@example.com", {
  name: "Jane Smith",
  plan: "pro"
});

GHOST.track(event, props)

JavaScript
GHOST.track("cta_clicked", {
  location: "pricing_hero",
  variant: "B"
});

๐Ÿ”’ Privacy & Opt-Out

Users can opt out locally with:

JavaScript
localStorage.setItem("disable-ghost-id", "1")

Or globally with:

JavaScript
window.__GHOSTID_OPTOUT__ = true
โš ๏ธ

When opted out, all Ghost Pixel tracking methods become no-ops.

๐Ÿงช Verifying Installation

JavaScript
// Check if Ghost Pixel is loaded
console.log(window.GHOST); // Should show the API object
console.log(GHOST.getVisitorId()); // Should return a visitor ID like "gv_abc12345_xyz98765"