mParticle integration with AppsFlyer

At a glance: mParticle, an AppsFlyer integrated partner, collects customer data and sends it to different analytics, marketing, and data warehousing platforms.

 Important!

Some media sources restrict sharing data with third parties. Therefore, postbacks for restricted events won't be sent to this partner, regardless of the configured selection for sending postbacks.

Event integrations

The purpose of this document is to provide you with details of how to activate event data from mParticle to AppsFlyer.

1. mParticle customers must integrate the AppsFlyer kit into their application. The mParticle SDK will initialize AppsFlyer’s SDK and will also forward all required lifecycle events to the AppsFlyer SDK.

2. Refer to the iOS and Android SDK GitHub repositories for details on how to configure the AppsFlyer kit with the mParticle SDK into your app.

Configure the AppsFlyer event integration

1. From the mParticle dashboard (https://app.mparticle.com), select your App (aka Workspace)

2. Click Directory from the left navigation

3. Click the AppsFlyer tile to display the integration details which provide information regarding the integration such as Categories, Available Platforms, Minimum mParticle SDK versions (if any), Data Types, User IDs, Device IDs and Available events, User IDs, Device IDs, and Available Configurations.

4. Click Add AppsFlyer to Setup.

The Add to Setup window opens:

5. Select the Output Event Integration Type and click Add to Setup to open the Event Configuration Setup screen where you can continue the configuration process.

6. Enter the AppsFlyer configuration settings and click Save:

  • Configuration Name
  • User same settings for Development and Production
  • Dev Key
  • The configuration you just created is shown under the AppsFlyer Default Group

The next step is to establish a connection between your input platforms to the AppsFlyer output event configuration.

7. Click Connections.

8. Select the Input (iOS in this example) and then click Connect Output.

9. Select the AppsFlyer tile and then select the AppsFlyer configuration created above.

10. Enter the AppsFlyer Connection settings:
Apple App ID (enter the number only and not the ID prefix. For example, if your App ID is id123456789 enter 123456789)

11. Click Add Connection.

AppsFlyer is now shown as a Connected Output Further options, such as Custom Mappings, may be available. See mParticle’s documentation for more.

Feed integrations

This section helps you understand how to connect a data feed from AppsFlyer to mParticle.

General integration information for AppsFlyer can be found at https://docs.mparticle.com/integrations/appsflyer/feed/.

1. From the mParticle Dashboard (https://app.mparticle.com), select your App (aka Workspace)

2. Click Directory from the left navigation

3. Click the AppsFlyer tile to display the integration details which provide information regarding the integration.

4. Click Add AppsFlyer to Setup.

5. Select the Input Feed Integration Type and click Add to Setup.

You are now taken to the Setup screen, where you can continue the configuration process.

6. Enter the AppsFlyer configuration settings and click Create:

  • Configuration Name
  • Act as Application

7. Complete the setup in the AppsFlyer dashboard using the authentication information provided.

Deferred deep linking

AppsFlyer allows you to access the user attribution data in real-time directly at the SDK level. It enables you to customize the landing page a user sees on the very first app open after a fresh app install. This is commonly referred to as “deferred” deep linking.

For more details of deferred deep linking, click here.

AppsFlyer conversion data contains a parameter called is_First_Launch. The value of is_First_Launch is 'true' on first launches only, and 'false' on all following launches. You can use this parameter to determine on every launch if the app should defer deep link to the user or not.

af_dp → $deeplink_path

Example

$deeplink_path=product/Banana-Pet-Costume/dd67268672b345e491656c871af8aa29

af_dp includes the encoded URI scheme and pathway

af_dp

%20jet%3A%2F%2Fproduct%2FBanana-Pet-Costume%2Fdd67268672b345e491656c871af8aa29

Android iOS
For Android: Perform this with Shared Preferences: here.
AttributionListener myListener = new AttributionListener() {
  @Override
  public void onResult(@NonNull AttributionResult attributionResult) {
   if (attributionResult.getServiceProviderId() == MParticle.ServiceProviders.APPSFLYER) {
    JSONObject attributionParams = attributionResult.getParameters();
    if (attributionParams != null && attributionParams.has(AppsFlyerKit.INSTALL_CONVERSION_RESULT)) {
     Log.d("Conversion result", attributionParams.toString());
    } else if (attributionParams != null && attributionParams.has(AppsFlyerKit.APP_OPEN_ATTRIBUTION_RESULT)) {
     Log.d("App open result", attributionParams.toString());
    }
   }
  }

  @Override
  public void onError(@NonNull AttributionError attributionError) {
   Log.d("Attribution Data Error", attributionError.toString());
  }
 };

 MParticleOptions options = MParticleOptions.builder(this)
  .credentials("replaceWithAPIKey", "replace-withAPISecret")
  .attributionListener(myListener)
  .build();

 MParticle.start(options);

AppsFlyer/mparticle use cases

Use Case Platform AppsFlyer SDK Method mParticle-AF Kit Method

Deferred Deep Llinking

iOS

onConversionDataSuccess

checkForDeferredDeepLinkWithCompletionHandler

Universal Links

iOS

continueUserActivity

continueUserActivity

App Open

iOS

onAppOpenAttribution

checkForDeferredDeepLinkWithCompletionHandler

Deferred Deep Linking

Android

onConversionDataSuccess

checkForDeepLink

Android App Links

Android

<intent-filter android:autoVerify="true">

continueUserActivity

App Open

Android

onAppOpenAttribution

checkForDeepLink

Handling user flags

AppsFlyer also enables you to serve personalized content or send existing users to specific locations in the app AFTER the initial launch. When existing users are deep linked into the app, the app opens from onOpenAttribution method, which returns the referring URL data.

 if let conversionData = params?[MPKitAppsFlyerConversionResultKey] as? [AnyHashable: Any], !alreadyLoggedAppsflyerConversionData {
   logAppsflyerConversionData(conversionData: conversionData)
   alreadyLoggedAppsflyerConversionData = true
   if let onelinkURL = (conversionData["af_dp"] as? String).flatMap(URL.init) {
    UIApplication.appDelegate._linkController.handle(onelinkURL, source: .appsflyer)
   }
  } else if let appOpenData = params?[MPKitAppsFlyerAppOpenResultKey] as? [AnyHashable: Any] {
   logAppsflyerAppOpenData(appOpenData: appOpenData as? [String: Any])
  }

AppsFlyer uses iOS UserDefaults and Android Shared Preferences to indicate whether the user is opening the app for the first time and should be redirected to the appropriate page, or if the app has already been opened and the user has already been directed to that page. To do this, the alreadyLoggedAppsflyerConversionData value is read and written to UserDefaults/ SharedPreferences, so that the value af_dp is not looked at on the first launch.

For more details about serving personalized content on deep linking click here.

Enabling AppsFlyer uninstall measurement in mParticle

AppsFlyer uninstall measurement isn't automatically enabled with the mParticle-AppsFlyer SDK kit. To measure app uninstalls, the AppsFlyer instance on mParticle must be configured.

To implement uninstall measurement for either iOS or Android: