Customer user ID field (CUID)

At a glance: Cross-reference your in-house data with AppsFlyer attribution data by the Customer user ID (CUID) field.

Implementing the CUID

The Customer user ID (CUID) field is a unique user identifier set by app and website owners.

  • CUID is reported by you to AppsFlyer using AppsFlyer APIs or SDKs.
  • AppsFlyer populates the CUID field in raw data reports accordingly.
  • Use the CUID to cross-reference AppsFlyer attribution data with your other data using the CUID as a key.
  • Example: A user with two devices has the same CUID ("1234567"). Each time they perform an event on a device, it is recorded along with the CUID. This enables the advertiser to aggregate both devices' raw data into a holistic view of the user.
  • CUID is used by AppsFlyer Audiences and People-Based Attribution solutions for improved accuracy and targeting.

CUID design and privacy

CUID implementation considerations

Use this API after considering your business logic and the following pros and cons:

  • Pros:
    • Attribution data is always associated with a CUID.
    • Use the CUID to associate attribution data with other data you have in your systems. 
    • This allows a more sophisticated use and processing of the data that you get from AppsFlyer.
  • Cons:
    • Actions and events that users perform, including purchases and subscriptions, aren't recorded in AppsFlyer until CUID is set. This can lead to discrepancies and increases exposure to fraud.

Developer instructions

To set your Customer User ID:

public void setCustomerUserId(String id);

Usage example:

AppsFlyerLib.getInstance().setCustomerUserId("myId");

We recommend setting the Customer User ID early in the app's flow, as it is only associated with events reported after its setup:

  • If setCustomerUserId is called before calling start, the Customer User ID appears in the raw data reports for installs and for events.
  • If it is set after, the Customer User ID is only associated with events that are recorded after setting the Customer User ID.
Getting Customer User ID

To avoid setting the Customer User ID value again beyond the first launch, and to reduce calls to your server to get the customer user ID, you can check if its value is empty or not by using:

AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID)
Delay SDK init for customerUserID

You can delay the SDK Initialization until the customerUserID is set.

To indicate that the SDK should delay initialization for the Customer User ID call:

AppsFlyerLib.getInstance().waitForCustomerUserId(true);

immediately before the init() method. The rest of the SDK initialization should remain unchanged.

Once the customerUserID has been provided, call

AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id", this);

to provide the SDK with the relevant Customer User ID and start the SDK.

The code should appear as follows:

Java Kotlin
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);
  }
}

People-Based Attribution

AppsFlyer People-based Attribution (PBA) gives you a broad perspective on the impact of web and mobile campaigns, as well as the ability to analyze your efforts to switch web users to your mobile app and vice versa.

You must set the same CUID in both mobile and web environments to enable cross-platform insights and analytics. 

Was this article helpful?