Enable deferred deep linking in your measurement SDK

After you’ve created deep links, you’ll need to enable them in your measurement SDK to use them in your App campaigns.

This article explains how to enable deferred deep linking (DDL) in supported third-party App Attribution Partners (AAPs) or in the latest Google Analytics for Firebase (GA4F) SDK. Learn how to track Mobile app conversion tracking with third-party tools.


Before you begin

To enable DDL in a supported AAP, you must have working deep links that are properly included in their attached feed or submitted as an ad group DDL.


Instructions

How to activate DDL in supported AAPs

Third-party AAPs currently supported by Google for DDL are as follows:

  • Adjust
  • AppsFlyer
  • Branch
  • Kochava
  • Singular
Note: Other AAPs are in different stages of development. Third-party deep links like AppsFlyer Onelinks and other 'smart links' aren’t supported. Contact your respective AAP representative for the latest updates on DDL enablement.

Follow the steps below to enable DDL in your chosen AAP.

Adjust

No additional settings required to enable DDL postbacks to Google Ads. If you want to disable or change this behaviour, you need to set up a deferred deep link callback.

AppsFlyer

  1. In AppsFlyer, click Configuration > Integrated Partners, then select Google Ads (Adwords).
  2. Under the Integration tab, enable 'Deferred deep linking with Google feeds'.
  3. Click Save integration.

Branch

You must be allowlisted by Branch to enable DDL postbacks. Contact the Branch support team to gain access to the feature.

Kochava

Ensure the 'Perform Deeplink Request' setting is enabled. This is set by default to enable DDL postbacks to Google Ads.

Singular

No additional settings required to enable DDL postbacks to Google Ads.

Learn more About tracking app conversions with an App Attribution Partner.

How to activate DDL in the GA4F SDK

You can activate DDL in the GA4F SDK using Android version 17.2.0+ or a newer version by following these steps:

Steps to activate DDL in the GA4F SDK

1. Configure your app to use Google Analytics for Firebase

In the app build.gradle, remove all dependencies on firebase-core. Then, add or update the dependency on firebase-analytics version 17.2.0+. The example below uses a newer version of the SDK.

dependencies {
    ...

    implementation 'com.google.firebase:firebase-analytics:21.0.0'
    ...
}

2. Enable the feature in your app

Modify your application manifest by adding the following metadata tag to your application tag.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myawesome.app"
>

    <uses-permission android:name="android.permission.INTERNET" />

    <application
     android:name=".MainActivity">

     <!-- Value to be added to enable deferred deep links -->
     <meta-data android:name="google_analytics_deferred_deep_link_enabled" android:value="true"/>

       <activity
            android:name=".MainActivity" >
       </activity>

    </application>

</manifest>

When enabled, GA4F will fetch the configured deep link, on app start, for the corresponding campaign you configured.

Note: Registering a receiver through the manifest comes with drawbacks such as memory usage and startup latency. These may be mitigated by favouring context registry.

3. Capture the deep link

Set up a SharedPreferences change listener within your main launch activity class. This will be triggered when a DDL is available. If you’re registering the listener later in the app lifecycle, the deep link might have already been retrieved. In that case, the listener won’t be triggered, and you can immediately look up the value of the deep link by reading SharedPreferences.

GA4F stores the deep link in a SharedPreferences file google.analytics.deferred.deeplink.prefs with the key deeplink. GA4F also stores, in the same SharedPreferences file, the ad click timestamp with the key timestamp. Note that the format of the timestamp is microseconds (milliseconds followed by a dot and microseconds) and is stored in SharedPreferences using a Long when the type is Double. Use Double.longBitsToDouble(...) to parse the actual value.

Example:

/**
* The main launch activity of the app.
*/

public class MainActivity extends AppCompatActivity {

  private SharedPreferences preferences;
  private SharedPreferences.OnSharedPreferenceChangeListener deepLinkListener;

    @Override
    protected void onStart() {
        super.onStart();
        preferences.registerOnSharedPreferenceChangeListener(deepLinkListener);
    }

    @Override
    protected void onStop() {
        super.onStop();
        preferences.unregisterOnSharedPreferenceChangeListener(deepLinkListener);
        deepLinkListener =
null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        preferences =
              getSharedPreferences(
'google.analytics.deferred.deeplink.prefs', MODE_PRIVATE);

        deepLinkListener = (sharedPreferences, key) -> {
            Log.d("DEEPLINK_LISTENER", "Deep link changed");
           if ("deeplink".equals(key)) {
              String deeplink = sharedPreferences.getString(key, null);
              Double cTime = Double.longBitsToDouble(sharedPreferences.getLong("timestamp", 0));
              Log.d('DEEPLINK_LISTENER', 'Deep link retrieved: ' + deeplink);
              showDeepLinkResult(deeplink);
            }
        };
    }

   public void showDeepLinkResult(String result) {
        String toastText = result;
        if (toastText == null) {
            toastText =
'The deep link retrieval failed';
        }
else if (toastText.isEmpty()) {
            toastText = 'Deep link empty';
        }

        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_LONG).show();
        Log.d("DEEPLINK", toastText);
    }
}

4. Prepare data for diagnostic testing

To validate your implementation, get the AdID for the device you wish to test with. You can use the following command to set the DDL that the app will receive.

curl 'googleadservices.com/pagead/conversion/app/deeplink?&rdid=<<your device adid>>&id_type=adid&bundleid=<<your application package>>&deeplink=<<deeplink you want to receive>>&ddl_test=1'

To check if the deep link was set correctly, you can use this request to verify the response.

curl 'googleadservices.com/pagead/conversion/app/deeplink?&rdid=<<your device adid>>&id_type=adid&bundleid=<<your application package>>&ddl_test=1'

This test deep link expires after 24 hours. Repeat this step if the test deep link expires.

5. Enable test mode for fetching the test DDL

Enable the DDL test mode to start testing on your devices.

adb shell setprop debug.deferred.deeplink <<your application package>>

Next, enable debug mode on your device. Begin using your app and, in Logcat, check that the log message shows a gmp_version of at least 18200. Searching for the keyword deferred will filter all debug messages from Google Analytics for Firebase relating to that functionality.

Example:

D/FA: Deferred Deep Link feature enabled.
FA-SVC:
Uploading data. app, uncompressed size, data: <<your application package>>,

gmp_version:
18200


Related links

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
14530533517002299631
true
Search Help Centre
true
true
true
true
true
73067
false
false
false