Install
<script src="https://your-host/api/public/cloak.js"
data-site-key="YOUR_SITE_KEY"
data-auto-redirect="1"></script>With data-auto-redirect="1" the SDK calls /decide on load and redirects to the money page automatically when the verdict is money.
Custom tracking flow
The tracker SDK is a telemetry client. Decisioning is performed by the cloak.js decision flow or a server-side integration; the tracker does not expose a client-controlled decision API.
<script src="https://your-host/api/public/tracker.js"
data-site-key="YOUR_SITE_KEY"></script>API surface
| Method | Description |
|---|---|
ShieldGate.track(kind, metadata?) | Queues a bounded custom telemetry event |
ShieldGate.step(name, metadata?) | Records a step_viewed event |
ShieldGate.button(name, metadata?) | Records a button_clicked event |
ShieldGate.conversion(payout?, metadata?) | Records a conversion and flushes telemetry |
ShieldGate.getFirstClick() | Returns the first-click attribution record, if available |
ShieldGate.sessionId() | Returns the current anonymous session identifier |
Auto-tracked events
pageview— on load and onhistory.pushStateclick— every<a>and<button>download— links to files (pdf, zip, exe, dmg, apk…)form_submit— form submissions (never captures values)
Custom events
ShieldGate.track('custom', { plan: 'pro', event: 'signup_completed' });
ShieldGate.step('checkout');
ShieldGate.button('buy_now');
ShieldGate.conversion(129.00, { order_id: 'order_123' });Data attributes
| Attribute | Effect |
|---|---|
data-site-key | Required — your site key |
data-auto-redirect | Redirect on money verdict |
data-endpoint | Override the API host |
data-debug | Log decisions to the console |
data-no-track | Disable auto-tracking |
SSR / no-JS fallback
Because bots often disable JS, use the server-side /decide or /dispatch contract for first-byte decisions and treat tracker telemetry as advisory. See Integrations.