Integrate with Mixpanel
Learn how to integrate Flagship with Mixpanel
How to push data to Mixpanel?
You might want to send data from Flagship to Mixpanel, to push experiments and features information and combine them with all your analytics dashboard. Hopefully, the method we're providing will help you reach that goal.
Reminder
The following custom integration isn’t under maintenance. It has been design to be generic, to work on the largest set of cases and codebase.
As a Yoda Master developer, you are the king of your own code.
The following code example takes into account that you already started your Flagship SDK and synchronized your user to get the flag (the modification) he should be assigned to.
The user is now seeing the flag, and you need to activate it, to alert us and count one more user in the corresponding report.
When activating it with our Flagship method, you will trigger the Mixpanel method at the same time and send the information you need to, like in the code example below.
It also implies that you imported the Mixpanel library before calling their method.
// Flagship campaign activation
flagshipVisitor.activateModification("my_flag");
// Get Flagship campaign information, map it, and send it to Mixpanel
MessageBuilder messageBuilder = new MessageBuilder("MIXPANEL_TOKEN");
MixpanelAPI mixpanel = new MixpanelAPI();
ClientDelivery clientDelivery = new ClientDelivery();
JSONObject campaignInfo = flagshipVisitor.getModificationInfo("my_flag");
if (properties != null) {
clientDelivery.addMessage(messageBuilder.event("distinctId", "flagship_event", campaignInfo));
mixpanel.deliver(clientDelivery);
}
// Flagship campaign activation
fsVisitorInstance.activateModifications([{ key: "my_flag" }]);
// Get Flagship campaign information and send it to Mixpanel
fsVisitorInstance
.getModificationInfo("my_flag")
.then((campaignInfo) => {
if (campaignInfo) {
mixpanel.track("flagship_event", campaignInfo);
}
})
.catch((error) => {
// Process error
});
// Flagship campaign activation
Flagship.activateModification("my_flag")
// Get Flagship campaign information, map it, and send it to Mixpanel
Flagship.getModificationInfo("my_flag")?.let { campaignInfo ->
mixpanel.track("flagship_event", campaignInfo)
}
// Flagship campaign activation
[[Flagship sharedInstance] activateModificationWithKey:@"my_flag"];
//Get Flagship campaign information and send it to Mixpanel
NSDictionary * campaign_info = [[Flagship sharedInstance] getModificationInfoWithKey:@"my_flag"];
if(campaign_info != nil){
//Mixpanel function to track
Mixpanel *mixpanel = [Mixpanel sharedInstance];
[mixpanel track:@"flagship_event" properties:campaign_info];
}
# Flagship campaign activation
$visitor->activateModification("my_flag");
# Get Flagship campaign information and send it to Segment
$mp = Mixpanel::getInstance("MIXPANEL_TOKEN");
$campaignInfo = $visitor->getModificationInfo("my_flag");
if($campaignInfo){
$mp->track("flagship_event", $campaignInfo);
}
// Flagship campaign activation
Flagship.sharedInstance.activateModification(key: "my_flag")
// Get Flagship campaign information and send it to Mixpanel
if let campaign_info = Flagship.sharedInstance.getModificationInfo(key: "my_flag") as? [String:MixpanelType]{
// Mixpanel function to track
Mixpanel.mainInstance().track(event: "flagship_event", properties:campaign_info)
}
Any feedback? We would be really happy to have a quick chat!
Updated 5 months ago