概要:您可以使用客户用户ID(CUID)字段将您的内部数据与AppsFlyer的归因数据相关联,以便进行对照参考。
CUID的使用
客户用户ID(CUID)字段是由应用或网站所有者设置的用户唯一标识符。
- CUID是由广告主通过AppsFlyer API或SDK上报给AppsFlyer的。
- AppsFlyer会根据此信息在原始数据报告中填充CUID字段。
- 您可以将CUID作为密钥,将AppsFlyer归因数据与您的其他数据进行对照。
- 举例:某用户的两个设备具有相同的CUID(“1234567”)。该用户在其中一个设备上完成了某个事件,AF会记录该事件并将其关联到上述CUID。这样,广告主就能将这两个设备的原始数据汇总到一起,从而对该用户有一个整体的了解。
- AppsFlyer的受众共享和PBA解决方案中会用到CUID,以优化准确性和定向能力。
CUID的设计及隐私合规
- AppsFlyer非常重视并尊重您和您用户的隐私。
- 我们不允许收集可直接识别身份的个人信息或将此类信息传输到AppsFlyer平台。
- 为了确保用户的隐私不受侵犯,在设计CUID时请勿涉及任何能直接识别用户身份的信息。比如,CUID中不能包含用户的邮箱地址、姓名、电话号码、社保卡号码等等。
- 相关文章:Google文档:避免发送个人身份信息的最佳做法
将SDK初始化延迟到CUID设置完毕
您可以等到CUID设置完毕后再进行SDK初始化。请根据您的业务逻辑做相应设置,同时需充分考虑到延迟SDK初始化的优劣势:
-
优势:
- 可确保归因数据能关联到CUID。
- 可使用CUID将归因数据关联到您系统中的其他数据。
- 可对AppsFlyer提供的数据进行更精细化的处理和利用。
-
劣势:
- CUID设置完毕之前AppsFlyer不会记录用户操作和事件,包括购买和订阅。这可能会导致数据差异,并且影响假量识别(在SDK初始化之前可能会识别不到假量)。
请注意:如果SDK等到CUID设置完毕后再启动,则在没有CUID的情况下,SDK不会上报任何数据(包括激活)。
设置CUID
安卓SDK的开发人员指南
请按以下方式设置您的客户用户ID:
public void setCustomerUserId(String id);
使用示例:
AppsFlyerLib.getInstance().setCustomerUserId("myId");
建议您在应用初始化后尽早设置CUID,因为只有在设置后上报的事件才能关联到相应的CUID,具体场景如下:
- 如果在调用
start
之前调用setCustomerUserId
,那么CUID会出现在激活和应用内事件的原始数据报告中。 - 如果CUID设置在调用start之后,则仅能关联到设置CUID之后记录到的事件。
为避免在首次启动后再次设置CUID的值,并减少向服务器请求CUID的次数,您可以使用以下方法检查该值是否为空:
AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID)
延迟SDK初始化以等待customerUserID
您可以将SDK的初始化延迟到customerUserID设置完成为止。
请调用以下方法,指示SDK将初始化延迟,以等待客户用户ID:
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
请紧接在init ()方法之前调用。SDK初始化的其他部分保持不变。
customerUserID设置完毕后 , 请调用:
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id",this);
该方法将为SDK提供相关的客户用户ID并启动SDK。
请写入以下代码:
public class AFApplication extends Application {
private static final String AF_DEV_KEY = "qrdZGj123456789";
@Override
public void onCreate() {
super.onCreate();
AppsFlyerConversionListener conversionDataListener =
new AppsFlyerConversionListener() {
...
};
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
//WARNING!Removing above line doesn't cancel its effect.
// Replace with this to stop waiting for CUID:
// AppsFlyerLib.getInstance().waitForCustomerUserId(false);
AppsFlyerLib.getInstance().init(AF_DEV_KEY,getConversionListener(), getApplicationContext());
AppsFlyerLib.getInstance().start(this);
// Do your magic to get the customerUserID
// ...
// any AppsFlyer SDK code invoked here will be discarded
//Call the following API once the customerUserID is available:
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id",this);
}
}
class AFApplication: Application() {
private val afDevKey = ""
override fun onCreate() {
super.onCreate()
val conversionDataListener = object: AppsFlyerConversionListener {
...
}
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
//WARNING!Removing above line doesn't cancel its effect.
// Replace with this to stop waiting for CUID:
// AppsFlyerLib.getInstance().waitForCustomerUserId(false);
AppsFlyerLib.getInstance().init(afDevKey,conversionDataListener, this)
AppsFlyerLib.getInstance().start(this)
// Do your magic to get the customerUserID
// ...
// any AppsFlyer SDK code invoked here will be discarded
// Call the following API once the customerUserID is available:
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id",this)
}
}
iOS SDK的开发人员指南
请按以下方式设置您的客户用户ID:
[AppsFlyerLib shared].customerUserID= @"my user id";
AppsFlyerLib.shared().customerUserID= "my user id"
在iOS环境中,如果您想让每次应用打开都带有CUID,建议您在应用初始化后尽早设置CUID,因为只有在设置后上报的事件才能关联到相应的CUID,具体场景如下:
- 如果在调用
start
之前调用setCustomerUserId
,那么CUID会出现在激活和应用内事件的原始数据报告中。 - 如果CUID设置在调用start之后,则仅能关联到设置CUID之后记录到的事件。
为避免在首次启动后再次设置CUID的值,并减少向服务器请求CUID的次数,您可以使用以下方法检查该值是否为空:
NSString *customerUserID = [AppsFlyerLib shared].customerUserID;
let customerUserID = AppsFlyerLib.shared().customerUserID
如果您想让激活和事件数据中都包含CUID,可以将SDK的初始化延迟到CUID设置完成为止。
请写入以下代码:
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSString *customUserId = [[NSUserDefaults standardUserDefaults] stringForKey:@"customerUserId"]; // Your custom logic of retrieving CUID
if (customUserId != nil && ![customUserId isEqual: @""]) {
[AppsFlyerLib shared].customerUserID = customUserId; // Set CUID in AppsFlyer SDK for this session
[[AppsFlyerLib shared] start]; // Start
}
}
func applicationDidBecomeActive(_ application: UIApplication) {
let customUserId = UserDefaults.standard.string(forKey:"customUserId") // your logic to retrieve CUID
if(customUserId != nil && customUserId != ""){
AppsFlyerLib.shared().customerUserID = customUserId // Set CUID in AppsFlyer SDK for this session
AppsFlyerLib.shared().start() // Start
}
}
基于用户的归因(PBA)
AppsFlyer基于用户的归因(PBA)功能让您更全面地了解PC端和移动端的投放效果,并分析PC端到移动端及移动端到PC端的转化情况。
您必须在移动及网页环境中设置相同的CUID,才能进行跨平台的数据衡量及分析。