All docs

Snippet

Retrieve the org-level tracking snippet and embeddable lead-capture form configuration

The snippet endpoints return the org-level tracking code and embeddable lead-capture form that you place on your website. They use the organisation’s first stream, so no stream ID is required.


Get Tracking Snippet

GET /snippet

Returns the same payload shape as GET /repos/{repo_id}/snippet but automatically resolves to the organisation’s first stream. Use this when you do not need to target a specific stream.

Example

cURL

curl "https://be.graph8.com/api/v1/snippet" \
  -H "Authorization: Bearer $API_KEY"

Response

{
  "data": {
    "write_key": "wk_abc123...",
    "tracking_host": "https://t.graph8.com",
    "domains": ["example.com"],
    "react_snippet": "import { G8Analytics } from '@graph8/nextjs'\n...",
    "script_tag": "<script src=\"https://t.graph8.com/p.js\" data-write-key=\"...\" data-tracking-host=\"...\" defer></script>",
    "config": {
      "write_key": "wk_abc123...",
      "tracking_host": "https://t.graph8.com",
      "project_id": "proj_xyz",
      "domains": ["example.com"]
    }
  }
}
FieldTypeDescription
write_keystringPublic write key used to authenticate tracking events
tracking_hoststringBase URL that the snippet sends events to
domainsarray of stringsDomains associated with this stream
react_snippetstringReady-to-use React/Next.js import snippet
script_tagstringHTML script tag for non-React sites
configobjectMachine-readable config object for custom integrations
config.write_keystringWrite key (same as top-level write_key)
config.tracking_hoststringTracking host (same as top-level tracking_host)
config.project_idstringInternal project identifier
config.domainsarray of stringsDomains list (same as top-level domains)

Get Form Snippet

GET /snippet/form

Returns the embeddable HTML lead-capture form along with its configuration — write key, tracking host, field list, and event name — ready to drop into any page.

Example

cURL

curl "https://be.graph8.com/api/v1/snippet/form" \
  -H "Authorization: Bearer $API_KEY"

Response

{
  "data": {
    "html": "<form id=\"g8-lead-form\">...</form><script>...</script>",
    "write_key": "...",
    "tracking_host": "https://t.graph8.com",
    "fields": ["name", "email", "company"],
    "event_name": "form_submitted",
    "notes": "..."
  }
}
FieldTypeDescription
htmlstringReady-to-embed HTML string containing the form markup and inline script
write_keystringPublic write key used by the snippet to authenticate tracking events
tracking_hoststringBase URL that the snippet sends events to
fieldsarray of stringsOrdered list of field names rendered in the form
event_namestringEvent name fired when the form is submitted
notesstringOptional implementation notes or instructions
Build with graph8