Prerequisites
- Node.js and npm or yarn installed.
- Access to your project’s frontend codebase.
- Your PlayerZero API Key.
Step-by-Step Instructions
1. Install the SDK
npm
yarn
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
This guide walks you through setting up the PlayerZero SDK using npm to start monitoring and improving your frontend applications.
npm i @goplayerzero/sdk-web --save
yarn add @goplayerzero/sdk-web
import PlayerZero from "@goplayerzero/sdk-web";
PlayerZero.init("your project id here");
PlayerZero.identify("user-id", {
name: "Jane Doe",
email: "jane@example.com",
group: "Engineering",
});
const userId = "userId";
const metadata = {
name: "<DISPLAY_NAME>",
email: "<USER_EMAIL>",
group: "<CUSTOMER_ID_OR_OTHER_GROUP>", // Optional
};
if (window.playerzero) {
window.playerzero.identify(userId, metadata);
} else {
window.addEventListener(
"playerzero_ready",
() => { window.playerzero.identify(userId, metadata) },
{ once: true }
);
}
const userId = "<USER_ID>";
const metadata = {
name: "<USER_NAME>",
email: "<USER_EMAIL>",
group: "<GROUP>", // optional
};
const setCookie = (traceId) => {
document.cookie = `pz-traceid=${traceId}; Path=/;`;
};
if (window.playerzero) {
// PlayerZero has loaded
window.playerzero.identify(userId, metadata);
window.playerzero.onTraceChange(setCookie);
} else {
// Wait for PlayerZero to load
window.addEventListener(
"playerzero_ready",
() => {
window.playerzero.identify(userId, metadata);
window.playerzero.onTraceChange(setCookie);
},
{ once: true }
);
}
Was this page helpful?