Load the browser client
Use the project Integration section to copy a snippet with your actual key, environment and endpoint. Load the script before creating the client. Do not include a private server key in browser code.
Integration structure
Replace the uppercase identifiers and application callbacks below with values from your own project. They are integration placeholders, not production visitor data.
// Load https://app.varypilot.com/sdk/v1/browser.min.js first.
const ab = new Varypilot.BrowserClient({
projectKey: PUBLIC_PROJECT_KEY,
environment: ENVIRONMENT_NAME,
endpoint: "https://varypilot-edge-api.silva-pires-ricardo86.workers.dev",
visitorId: STABLE_PSEUDONYMOUS_VISITOR_ID,
consent: false
});
await ab.init();
ab.setConsent(ANALYTICS_CONSENT_GRANTED);
const variant = ab.getVariant(EXPERIMENT_KEY, CONTROL_VARIANT_KEY);
renderAssignedExperience(variant);
ab.trackExposure(EXPERIMENT_KEY, variant);
// At the actual outcome:
ab.track(GOAL_EVENT_NAME, { eventId: STABLE_EVENT_ID });
await ab.flush();Connect consent changes
Default analytics recording to false until your own consent platform grants it. Propagate later consent changes with setConsent. Assignment and analytics recording are separate operations.
The SDK can cache configuration, but cache availability does not grant subscription or routing access indefinitely. Refresh and delivery state still matter.