Is it possible to trigger session recordings only when certain UTM conditions are met? For example, if UTM source contains XYZ, start session recording. Otherwise, don't start.
Hi Khushi L., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
It’s not documented as a built‑in, declarative option (e.g. “only record when UTM source = X”), but you can achieve this behavior using manual start/stop of Session Replay in your own code.On Web, you can: 1. Initialize Mixpanel with record_sessions_percent: 0 so nothing is recorded by default.
2. In your app, read the UTM parameters from the URL.
3. If the condition matches (e.g. utm_source contains XYZ), call mixpanel.start_session_recording() to force recording on; otherwise, do nothing.start_session_recording() “forces recording to begin, regardless of the record_sessions_percent init option,” and is explicitly recommended for cases like “only record certain types of users” or “only record users utilizing certain features.”[JS replay capture]Example pattern (pseudo‑code): js mixpanel.init('<YOUR_PROJECT_TOKEN> ', { record_sessions_percent: 0 // default: no sessions recorded });LBKS// after init, once you can read URL params: const params = new URLSearchParams(window.location.search); const utmSource = params.get('utm_source') || '';LBKSif (utmSource.includes('XYZ')) { mixpanel.start_session_recording(); }LBKSYou can similarly call mixpanel.stop_session_recording() when a user navigates to areas you don’t want recorded.[JS replay capture; Replay privacy controls]The docs do not mention UTM‑based conditions specifically, but they do support this general “only record certain users/contexts” pattern via manual start/stop.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
