Learn how to unlock advanced features of the PlayerZero Web SDK, including custom event tracking, devtools integrations, and fine-tuning behavior for your application.
PlayerZero.track("checkout", { item: "chocolate" });
const url = playerzero.devtools(); console.log("PlayerZero Devtools URL", url);
PlayerZero.init(apiToken: string)
- Initialize PlayerZero with your project’s API token. Find your API token on the Settings > API Tokens page.
PlayerZero.identify(userId: string, metadata: Record<string, unknown>)
- Identify a user with metadata.
PlayerZero.setUserVars(metadata: Record<string, unknown>)
- Set additional metadata on the current user without re-identifying.
PlayerZero.track(event: string, metadata?: Record<string, unknown>)
- Track an event in PlayerZero.
PlayerZero.prompt()
- Open the Devtools share window.
playerzero.devtools(): string
- Returns a URL that opens the current session in devtools.
playerzero.traceId(): string
- Returns the current trace ID for the session.
playerzero.onTraceChange(callback: (traceId: string) => void)
- Register a callback function that gets called when the trace ID changes.
playerzero.kill(reason?: string)
- Permanently shut down PlayerZero on the current page session.
playerzero.prompt()
method.
This allows you to integrate a custom trigger (like a button) anywhere in your application UI. The function is available globally when PlayerZero is active on the page.
You can even test this directly in your browser console by running playerzero.prompt()
on a page where PlayerZero is initialized.
window.fetch
or XMLHttpRequest
.
<head>
— before any third-party libraries are loaded.
This ensures that PlayerZero wraps window.fetch
before any other library does, giving it access to monitor requests and errors reliably.
If this problem doesn’t apply to you, you can safely ignore this step.