I’m having difficulty comparing campaign performance due to ATT limitations. How do I set up campaign-level tracking and reporting in Mixpanel?
Hi Robert T., 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
To set up campaign-level tracking and reporting in Mixpanel, especially in light of ATT (App Tracking Transparency) limitations, you can follow these steps:1. Implement ad spend tracking: Mixpanel allows you to track ad campaign performance by integrating your ad network data. This involves sending aggregated campaign data to Mixpanel as events, which can then be analyzed alongside your in-app user behavior data.2. Use the "Ad Data" event: Create an event called "Ad Data" that includes properties such as campaign ID, source, cost, clicks, and impressions. This event should be sent once per day for each campaign, aggregating the daily performance metrics Understanding the Data Model.3. Include campaign metadata: Add UTM parameters as properties to your "Ad Data" event, such as utm_source, utm_medium, utm_campaign, etc. This allows you to match the ad data with your client-side tracking Understanding the Data Model.4. Use Insert ID: To prevent duplicate data, include an Insert ID property in your "Ad Data" event. This should be a unique identifier composed of the ad network name, date, and campaign ID Understanding the Data Model.5. Set up integrations: Mixpanel provides detailed guides for integrating with major ad networks like Google Ads and Facebook Ads. These integrations can automate the process of sending ad performance data to Mixpanel Ad Spend Integration.6. Create reports: Once your data is in Mixpanel, you can create reports to analyze campaign performance. The Experiments report can give you an overview of all your running experiments Using the events in Mixpanel.7. Build cohorts: You can create cohorts of users exposed to different campaign variants and use these cohorts to filter or breakdown your data in any Mixpanel report Using the events in Mixpanel.By implementing this approach, you can track and analyze your campaign performance at a campaign level, even with ATT limitations. This method focuses on aggregated campaign data rather than individual user data, allowing you to measure ROAS (Return on Ad Spend) and other key metrics in the context of in-product conversions.
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! 📚
To tie campaigns to users using the method described earlier, you'll need to implement a combination of server-side and client-side tracking. Here's how you can do this: 1. Server-side attribution: When a user clicks on an ad and lands on your website or app, capture the UTM parameters or other campaign identifiers on the server-side. Here's an example of how to do this using Python:
python
from urllib.parse import urlparse
from mixpanel import Mixpanel
mp = mixpanel.init("YOUR_TOKEN")
def track_to_mp(request, event_name, properties):
if "Referer" in request.headers:
properties.update({
"$referrer": request.headers["Referer"],
"$referring_domain": urlparse(request.headers["Referer"]).hostname
})
utm_keys = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"]
utm_values = {key: request.args[key] for key in utm_keys if request.args.get(key)}
properties.update(utm_values)
properties["ip"] = request.remote_addr
mp.track(request.user_id, event_name, properties)
This code captures UTM parameters and referrer information from the request and sends it to Mixpanel [Server-Side Attribution](https://docs.mixpanel.com/docs/tracking-best-practices/traffic-attribution#server-side-attribution). 2. Client-side tracking: On the client-side, implement both first-touch and last-touch UTM tracking. This allows you to attribute users to their original acquisition channel and their most recent interaction. Here's a JavaScript example:
javascript
function campaignParams() {
var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' ')
var kw = ''
var last_params = {}
var first_params = {}
for (index = 0; index < campaign_keywords.length; ++index) {
kw = getQueryParam(document.URL, campaign_keywords[index]);
if (kw.length) {
last_params[campaign_keywords[index] + ' [last touch]'] = kw;
first_params[campaign_keywords[index] + ' [first touch]'] = kw;
}
}
mixpanel.people.set(last_params);
mixpanel.register(last_params);
mixpanel.people.set_once(first_params);
}
campaignParams();
This code sets both last-touch and first-touch UTM parameters as user properties [Last-Touch UTM tracking](https://docs.mixpanel.com/docs/tracking-best-practices/traffic-attribution#last-touch-utm-tracking). 3. User identification: When a user signs up or logs in, make sure to call Mixpanel's identify() method with a unique user identifier. This ties all the previous anonymous events (including campaign data) to the user's profile. 4. Use Mixpanel's ID Merge feature: This allows you to attribute cross-platform events as well as pre and post-login events to individual users. Implement ID Merge using Mixpanel's Client-Side SDK [ID Merge Implementation](https://www.youtube.com/watch?v=FnItIYNpBrM).
5. Create cohorts: Once you have this data in Mixpanel, you can create cohorts based on campaign attributes. For example, you could create a cohort of users who came from a specific UTM source or campaign.6. Analyze in reports: Use these cohorts in your Mixpanel reports to analyze how users from different campaigns behave in your product. You can use the Funnels report to see how users from different campaigns convert through your product funnel Getting specific with user metrics.By implementing these steps, you'll be able to tie campaign data to individual users, allowing you to analyze how different campaigns impact user behavior and conversion throughout their lifecycle in your product.
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! 📚
Certainly! I'll focus specifically on mobile app attribution and tracking for Mixpanel. Here's a revised approach for tying campaigns to users in mobile apps: 1. Mobile Attribution Partners: Mixpanel recommends partnering with a mobile attribution service to reliably map the user journey, especially for app installs. Mixpanel has a list of partners that specialize in mobile attribution [Mobile Attribution](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking). 2. SDK-to-SDK Integration: One of the recommended methods for mobile attribution is the SDK-to-SDK integration. Here's how it works: - Install both the attribution partner's SDK and Mixpanel's SDK in your app. - When the app launches for the first time, use the partner's SDK to query the attribution data asynchronously. - Once you receive the data, you can track it through Mixpanel's SDK. Here's an example using Adjust (chosen alphabetically from Mixpanel's partners):
java
private void trackAttribution(AdjustAttribution attribution) {
if (isAttributionAlreadyStored()) {
return; // data already stored, nothing to do
}
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);
storeAttribution(props); // store the data for later use
mixpanel.track("install", props); // send the install event
}
This approach allows you to tie the attribution data directly to the user in Mixpanel [SDK to SDK Integration](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking#sdk-to-sdk). 3. Identify Users: When a user signs up or logs in, use Mixpanel's identify() method to tie the attribution data to the user's profile. 4. Super Properties: Mixpanel's mobile SDKs automatically send certain properties with all events, including an abstracted user id and device information. These "super properties" can help tie campaign data to specific users [Properties sweeten the deal](https://mixpanel.com/blog/what-is-mobile-app-event-tracking/). 5. App Links Tracking: For both Android and iOS, Mixpanel supports tracking in-bound and out-bound App Links. This can provide additional information about how users are getting to and from your mobile app [App Links Tracking](https://docs.mixpanel.com/docs/tracking-methods/sdks/android#app-links-tracking). By implementing these methods, you can effectively tie campaign data to individual users in your mobile app, allowing you to analyze how different campaigns impact user behavior and conversion throughout their lifecycle in your app.
Remember, while Mixpanel offers automatic event tracking, it's generally recommended to disable this feature (trackAutomaticEvents: false
) during initialization, as these events can be unreliable Legacy Automatically Tracked Events.This approach focuses specifically on mobile app attribution and tracking, providing a more accurate and reliable method for tying campaigns to users in a mobile environment.
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.