kapa.ai want to track the events and user properties as per the utm params, including campaign name, source (meta/google/organic) etc across platforms what could be the best way to do thi, right now, we are not getting any of these params in mix panel filters
You’re not seeing UTM / campaign data in Mixpanel because they’re only auto-captured in specific cases, and must be set manually in others.Here’s how to get reliable UTM + campaign/source data across platforms: ---
1. Web (JavaScript SDK)
If you use the Mixpanel JS SDK on your website, UTM params are automatically added to events from that page load: - Auto-captured event properties: utm_source, utm_medium, utm_campaign, utm_term, utm_content, utm_id, utm_source_platform, utm_campaign_id, utm_creative_format, utm_marketing_tactic.[JS UTM tags]
- First-seen values are also stored on the user profile as initial_utm_** properties for acquisition analysis.[JS UTM tags; Web attribution]**Checklist:**1. Make sure you’re actually using the JS SDK on the pages where users land from ads.
2. Initialize it normally (or with stop_utm_persistence: true if you plan to use Mixpanel Attribution):
js
mixpanel.init('YOUR_PROJECT_TOKEN', {
stop_utm_persistence: true // recommended for Attribution
});
```LBKSLBKS3. Confirm your landing URLs really contain lowercase UTM params (e.g. `?utm_source=google&utm_medium=cpc...`). UTM tracking is case-sensitive.[[JS UTM tags](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#track-utm-tags)]
4. In Mixpanel, open an event in **Events* and check if UTM properties appear in the property list. If they do, you can then use them as filters/breakdowns.LBKSIf you’re only sending events from your backend (no JS), see section 2.LBKS---
2. Server-side / Backend Events (web or API)
Server-side implementations do not auto-capture UTM or referrer. You must extract them from the incoming request and add them as event properties yourself.[Server-side best practices; Server-side attribution]Example pattern (Python-style pseudocode): LBKSfrom urllib.parse import urlparse from mixpanel import MixpanelLBKSmp = Mixpanel("YOUR_TOKEN")LBKSdef track_to_mp(request, event_name, properties): # Referrer if "Referer" in request.headers: properties.update({ "$referrer": request.headers["Referer"], "$referring_domain": urlparse(request.headers["Referer"]).hostname })LBKS # UTM params from query string utm_keys = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"] utm_values = {k: request.args[k] for k in utm_keys if request.args.get(k)} properties.update(utm_values)LBKS properties["ip"] = request.remote_addr mp.track(request.user_id, event_name, properties)LBKSDo this for all key events you care about (signup, purchase, etc.). Once these properties are present on events, they’ll show up in Mixpanel filters.---
3. Mobile Apps (iOS / Android)
Mobile SDKs do not auto-capture UTM from URLs. You need to: 1. Use a mobile attribution provider (e.g. Adjust, AppsFlyer, etc.) or your own deep-linking logic to get campaign/source data on first app open.
2. When you receive attribution data on device, send it to Mixpanel as event properties (e.g. on an Install or App Open event) and optionally store it locally for reuse.[Mobile attribution SDK]Example idea (Android + Adjust): LBKSprivate void trackAttribution(AdjustAttribution attribution){ if(isAttributionAlreadyStored()){ return; } JSONObject props = new JSONObject(); insertJsonProperty(props, "utm_source", attribution.network); insertJsonProperty(props, "utm_campaign", attribution.campaign); insertJsonProperty(props, "utm_medium", attribution.adgroup);LBKS storeAttribution(props); mixpanel.track("Install", props); }LBKSYou can also set these as super properties so they’re attached to most subsequent events.[Special properties]---
4. Ad Network Spend / Campaign Data (Google, Meta, etc.)
If you also want daily spend/clicks/impressions by campaign in Mixpanel, send Ad Data events from your ad platforms with matching UTM fields: js { event: 'Ad Data', properties: { time: 1680307200000, source: 'Google', campaign_id: 12345, cost: 37.19, clicks: 11, impressions: 482, utm_source: "google", utm_medium: "cpc", utm_campaign: "spring_sale" } }LBKS
This lets you join ad performance with user behavior via shared UTM properties.[Ad spend model]---
5. Why you don’t see UTM in filters now
Common reasons: - Only server-side events are being sent and UTM/referrer are never added. - JS SDK is not installed on landing pages, or initialized incorrectly. - UTMs are missing or not lowercase in URLs. - You’re looking at events that occur later in the journey (e.g. mobile events) that never had UTM properties attached.---
6. Recommended “best way” across platforms
1. Web: Use JS SDK on all landing pages; rely on its automatic UTM + initial_utm_** capture.[Web attribution]
2. Server-side: Always parse UTMs + referrer from the incoming request and attach them to key events.
3. Mobile: Use an attribution SDK or deep links to get campaign/source, then send them to Mixpanel as event properties and/or super properties.
4. *Naming: Standardize on the same property names (utm_source, utm_medium, utm_campaign, etc.) everywhere so you can filter/break down consistently.[Tracking strategy]If you tell me which platforms you have (e.g. “React web + Node backend + iOS + Android”), I can outline the exact minimal changes needed in each.
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.
Let me check the knowledge base for you again. One moment! 📚
On mobile, Mixpanel does not auto-capture UTM / campaign data. You need to bring in attribution data (from Play Store / App Store flows or a partner) and then send it to Mixpanel as event properties and/or super properties.There are two main recommended patterns in the docs: ---
1. Use a Mobile Attribution Partner (recommended)
Mixpanel recommends using a mobile attribution tool (Adjust, AppsFlyer, Branch, etc.) and integrating it with Mixpanel.[Mobile attribution; Mobile attribution overview]There are two good ways to wire this:
A. SDK → SDK (on-device)
1. Install the partner SDK in your iOS/Android app.
2. On first app launch, query the attribution data from the partner SDK.
3. When you receive it, send an Install (or similar) event to Mixpanel with properties like utm_source, utm_medium, utm_campaign, etc.
4. Optionally store those values locally and/or as Mixpanel super properties so they’re attached to future events.The docs show this pattern with Adjust on Android:[SDK to SDK]LBKSprivate void trackAttribution(AdjustAttribution attribution){ if(isAttributionAlreadyStored()){ // check if already stored on device return; } JSONObject props = new JSONObject(); insertJsonProperty(props, "[Adjust]Network", attribution.network); insertJsonProperty(props, "[Adjust]Campaign", attribution.campaign); insertJsonProperty(props, "[Adjust]Adgroup", attribution.adgroup); insertJsonProperty(props, "[Adjust]Creative", attribution.creative);LBKS storeAttribution(props); // save locally for later use mixpanel.track("install", props); // send install event to Mixpanel }LBKSYou can adapt this by mapping partner fields to UTM-style names, for example: - utm_source ← network (e.g. facebook, google)
- utm_campaign ← campaign
- utm_medium ← adgroup or channelThis approach: - Keeps all IDs consistent (Mixpanel SDK sends events).
- Requires no extra server infrastructure.[SDK to SDK]
B. Webhooks / Callbacks (server-based)
1. Configure the partner to send install/re-engagement callbacks to your server.
2. The callback payload includes a device/install ID and attribution data.[Webhooks]
3. On your server, map that device/install ID to the user’s Mixpanel distinct_id.
4. From your server, send events or profile updates to Mixpanel with properties like utm_source, utm_campaign, etc.This is more flexible but requires server work.[Webhooks]---
2. Platform-specific without a Partner
If you don’t use a partner: - Android: You can use Google’s Play Install Referrer Library to get a referrer URL on first open, parse it, and send the parsed UTM params to Mixpanel as event properties.[Mobile attribution] - iOS: The App Store strips attribution data; you cannot directly get UTM/campaign info for installs without a partner.[Mobile attribution]So for iOS, a mobile attribution partner is effectively required if you want reliable campaign/source data.---
3. Persisting Campaign Data on Mobile
Once you have the attribution data on device (from SDK → SDK or Play Install Referrer): 1. Send it on an Install / First Open event.
2. Optionally register it as super properties so it’s attached to all subsequent events from that device (e.g. utm_source, utm_medium, utm_campaign). The docs show how to set super properties on:
- Android: mixpanel.registerSuperProperties(...)[Android super props]
- iOS Swift: Mixpanel.mainInstance().registerSuperProperties(...)[iOS Swift super props]
- iOS Obj‑C: [mixpanel registerSuperProperties:...][iOS ObjC super props]Use the same property names across platforms (utm_source, utm_medium, utm_campaign, etc.) so you can filter/break down consistently in Mixpanel.---If you tell me your exact stack (Android only / iOS only / both, and which attribution partner if any), I can map this into a concrete step-by-step for your case.
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.
Let me check the knowledge base for you again. One moment! 📚
Short answer: sending UTM data only as user properties will not fully solve this. It helps for some use cases, but has important limitations.
How Mixpanel joins data
- Events and user profiles are stored separately and joined at query time on distinct_id.[Data model; User profiles FAQ]
- When you use user properties in filters/breakdowns, Mixpanel uses the latest value on the profile for all of that user’s events (past and future).[User profiles FAQ]
What works if you use only user properties
If you set e.g. initial_utm_source, initial_utm_medium, initial_utm_campaign as user properties (like the JS SDK does automatically on web), you can: - Filter/break down events by acquisition channel (first-touch): “Show all events for users whose initial_utm_source = google”.[Default user properties; Web attribution]This is good for “what channel acquired this user?” type questions.
What you lose if you only use user properties
Because user properties are just the current snapshot: - You cannot analyze changes in attribution over time (e.g. user first came from google, later from meta) – only the latest value is visible.[User profiles FAQ]
- You cannot do multi-touch or last-touch attribution correctly, because attribution models in Mixpanel expect UTM params as event properties on each touchpoint.[Attribution feature; Traffic attribution note]
- If you overwrite the UTM user property later, all historical events will appear as if they belonged to the new value, since the join always uses the latest profile state.[User profiles FAQ]
Recommended pattern
Best practice is: 1. UTMs as event properties on every relevant event (page view, app open, signup, purchase, etc.). This is required for:
- Filtering/breaking down per event occurrence.
- Using Mixpanel’s Attribution models.[Web attribution; Attribution feature]2. Optionally also store first-touch UTMs as user properties (e.g. initial_utm_source, initial_utm_campaign) for acquisition-level analysis, like the JS SDK does.[Default user properties; Traffic attribution FAQ]So: - Yes, if you send UTMs as user properties, you can filter events by those user properties.
- But for robust, accurate attribution and per-event breakdowns, you should still send UTMs as event properties on mobile events, and use user properties only as a complementary “initial_*” snapshot.
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.
