Step 2 — Add the Autoplay snippet in your frontend
Add the snippet below to your frontend and replace the placeholders with the API key and Product ID from your Autoplay dashboard.
import posthog from 'posthog-js'posthog.init('YOUR_AUTOPLAY_API_KEY', { api_host: 'https://us.i.posthog.com', person_profiles: 'identified_only', session_idle_timeout_seconds: 120, // stop capturing after 2 min of inactivity loaded: (posthog) => { posthog.identify(posthog.get_distinct_id(), { product_id: 'YOUR_AUTOPLAY_PRODUCT_ID', }); },})
YOUR_AUTOPLAY_API_KEY — found in your Autoplay dashboard under API keys.YOUR_AUTOPLAY_PRODUCT_ID — found in your Autoplay dashboard under your product settings. Tells Autoplay which connector to route your events to.session_idle_timeout_seconds: 120 stops capturing when a user has been inactive for more than 2 minutes, keeping your event stream clean.
Once a user logs in, call posthog.identify() again with their email. This lets Autoplay automatically link their PostHog session to their chatbot conversation — no extra frontend work required.
// Call this after your auth flow resolvesposthog.identify(user.id, { product_id: 'YOUR_AUTOPLAY_PRODUCT_ID', email: user.email,})
Email is optional — anonymous sessions are captured and routed correctly without it. Providing it enables identity-based conversation linking.
Once your snippet is live, join our Slack workspace and drop a message in #just-integrated. We’ll confirm your events are flowing and get your connector set up right away.
Once your snippet is live and events are flowing, join our Slack workspace and the #just-integrated channel — we’ll send you a 1Password link containing your connector URL and API token.👉 Join our Slack workspaceOnce you’re in, we will:
Configure a PostHog webhook destination pointed at your connector
Share your connector URL and API token via a secure 1Password link
Nothing else is required on your end — Autoplay handles the webhook configuration, event normalisation, and session grouping automatically.
Replace the placeholders with your connector URL and API token, then run the script. It will connect to the stream and print every event as it arrives.