概要:
6257(1)
AppsFlyer SDK为移动应用提供安装和应用内事件的追踪。
您可以追踪安装、更新和互动以及应用安装以外的其他应用内事件(包括应用内购买、游戏级别等),以评估 ROI 和用户互动水平。
重要提示!
1. 对接流程
重要提示!
2.
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
this .InitializeComponent();
this .Suspending += this .OnSuspending;
AppsFlyerLib. AppsFlyerTracker tracker =
AppsFlyerLib. AppsFlyerTracker .GetAppsFlyerTracker();
tracker.appId = "YOUR_APP_ID_HERE" ;
tracker.devKey = "YOUR_DEV_KEY_HERE" ;
tracker.trackAppLaunch();
}
tracker.TrackAppLaunchAsync(Callback);
public void Callback(AppsFlyerLib.ServerStatusCode code)
{
if(code == AppsFlyerLib.ServerStatusCode.SUCCESS) {
//success scenario
} else if(code == AppsFlyerLib.ServerStatusCode.FAIL) {
//failure scenario
}
}
3.
public void TrackEvent(string eventName, IDictionary<string, Object> eventValues)
- 您可以输入任意正负数值。
示例
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
IDictionary<string, object> eventValues = new Dictionary<string, object>();
eventValues.Add(AppsFlyerLib.AFInAppEventParameterName.CONTENT_ID, "id123");
eventValues.Add(AppsFlyerLib.AFInAppEventParameterName.REVENUE, "10");
eventValues.Add(AppsFlyerLib.AFInAppEventParameterName.CURRENCY, "USD");
tracker.TrackEvent(AppsFlyerLib.AFInAppEventType.ADD_TO_CART, eventValues);
tracker.TrackEventAsync(AppsFlyerLib.AFInAppEventType.PURCHASE, events, Callback);
public void Callback(AppsFlyerLib.ServerStatusCode code)
{
if(code == AppsFlyerLib.ServerStatusCode.SUCCESS) {
//success scenario
} else if(code == AppsFlyerLib.ServerStatusCode.FAIL) {
//failure scenario
}
}
4. 高级对接
除了随着应用内事件发送到 AppsFlyer 的指定货币代码外,您还可以使用下面的 API 来设置全球货币代码。
使用以下 API 设置货币代码:
tracker.currencyCode = "GBP";
用户每次安装一个应用后,AF都会为其匹配一个非重的AppsFlyer ID。
public string getAppsFlyerUID()
该 ID 可以通过 Postback API 在 AppsFlyer CSV 报告中得到,用于与您的内部 ID 交叉引用。
请按以下方式设置您的客户用户ID:
tracker.customerUserId = "YOUR_CUSTOMER_USER_ID";
Task.Run(async () =>
{
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
string conversionData = await tracker.GetConversionDataAsync();
});
AppsFlyerLib::AppsFlyerTracker^ tracker = AppsFlyerLib::AppsFlyerTracker::GetAppsFlyerTracker();
tracker->appId = ref new Platform::String(L"APP_KEY");
tracker->devKey = ref new Platform::String(L"APPSFLYER_KEY");
tracker->TrackAppLaunch();
create_task(tracker->GetConversionDataAsync()).then([tracker](Platform::String^ conversionData)
{
Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ eventValues
= ref new Platform::Collections::Map<Platform::String^, Platform::Object^>();
eventValues->Insert(AppsFlyerLib::AFInAppEventParameterName::CONTENT_ID, "134");
eventValues->Insert(AppsFlyerLib::AFInAppEventParameterName::CONTENT_TYPE, "Virtual Goods");
eventValues->Insert(AppsFlyerLib::AFInAppEventParameterName::CURRENCY, "USD");
eventValues->Insert(AppsFlyerLib::AFInAppEventParameterName::REVENUE, "9.99");
tracker->TrackEvent(AppsFlyerLib::AFInAppEventType::PURCHASE, eventValues);
});