帮助中心
|
Mixpanel SDK 集成
请注意:
您可以按照此指南的说明集成 Adjust SDK 和 Mixpanel SDK。
操作前须知
要使用该功能,请先为您的平台下载并设置对应的 Adjust SDK。按照下方链接中的说明操作,开始使用功能。
指南
Mixpanel API 允许您注册“超级属性“。这些属性可随所有活动发送。请参考Mixpanel 的文档了解更多信息。
要集成 Adjust SDK 和 Mixpanel SDK,您需要注册“超级属性”。收到 Adjust 后端响应后,您应该发送此信息。为此,请按照归因回传指南中相应平台的说明进行操作。
示例
如下方所示调整回传方法来使用 Mixpanel API:
Objective-C
- (void)adjustAttributionChanged:(ADJAttribution *)attribution {
Mixpanel *mixpanel = [Mixpanel sharedInstance];
// The adjust properties will be sent
// with all future track calls.
if (attribution.network != nil)
[mixpanel registerSuperProperties:@{@"[Adjust]Network": attribution.network}];
if (attribution.campaign != nil)
[mixpanel registerSuperProperties:@{@"[Adjust]Campaign": attribution.campaign}];
if (attribution.adgroup != nil)
[mixpanel registerSuperProperties:@{@"[Adjust]Adgroup": attribution.adgroup}];
if (attribution.creative != nil)
[mixpanel registerSuperProperties:@{@"[Adjust]Creative": attribution.creative}];
}
Swift
func adjustAttributionChanged(_ attribution: ADJAttribution?) {
let mixpanel = Mixpanel.sharedInstance()
// The adjust properties will be sent
// with all future track calls.
if attribution?.network != nil {
if let network = attribution?.network {
mixpanel?.registerSuperProperties([
"[Adjust]Network": network
])
}
}
if attribution?.campaign != nil {
if let campaign = attribution?.campaign {
mixpanel?.registerSuperProperties([
"[Adjust]Campaign": campaign
])
}
}
if attribution?.adgroup != nil {
if let adgroup = attribution?.adgroup {
mixpanel?.registerSuperProperties([
"[Adjust]Adgroup": adgroup
])
}
}
if attribution?.creative != nil {
if let creative = attribution?.creative {
mixpanel?.registerSuperProperties([
"[Adjust]Creative": creative
])
}
}
}
Java
public class YourApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
// Configure Adjust.
AdjustConfig config = new AdjustConfig(this, appToken, environment);
config.setOnAttributionChangedListener(newOnAttributionChangedListener() {
@Override
public void onAttributionChanged(AdjustAttribution attribution) {
MixpanelAPI mixpanel = MixpanelAPI.getInstance(context,MIXPANEL_TOKEN);
// The Adjust properties will be sent with all future track calls.
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);
if (props.length()> 0) {
mixpanel.registerSuperProperties(props);
}
}
private void insertJsonProperty(JSONObject props, String name, String value) {
try {
if (value != null) {
props.put(name,value);
}
} catch(JSONException e) { }
}
});
Adjust.onCreate(config);
}
}