Google Analytics integration—custom dimensions

At a glance: Setup the integration with Google Analytics using custom dimensions.

 Related reading

For a complete picture of working with Google Analytics in AppsFlyer, check out these articles:

Custom dimensions on Google Analytics

There is another method for sending AppsFlyer's attribution data to Google analytics, that is set up on GA and not on AppsFlyer's dashboard.


The Custom Dimensions method IS NOT RECOMMENDED due to the following:

  • Integrating Google Analytics through AppsFlyer dashboard is simple, quick and easy
  • Integrating Google Analytics using Custom Dimensions is complicated and error-prone
  • Using Custom Dimensions requires you to use both AppsFlyer SDK and Google Analytics SDK
  • Using Custom Dimensions has a greater potential of causing discrepancies

Advertisers that use the new integration with Google Analytics don't need to use the custom dimensions method.


This method requires you to integrate GA SDK into your app.

Setting media source as a custom dimension on Google Analytics

Google Analytics has a powerful tool to create user-level segmentation called custom dimensions. The custom dimension values are sent from mobile devices and your reports are generated, based on these dimensions from your Google Analytics dashboard.

Step 1: Define it on Google Analytics

  1. Select your app from the GA menu
  2. Select Admin at the top bar on GA dashboard
  3. On the PROPERTY column select Custom Definition
  4. Select Custom Dimensions

  5. Create a new dimension. Call it AppsFlyer Media Source and make sure you select User scope. This ensures the data is saved over multiple sessions.


    Each dimension is created with an index that you must remember so you can later use it in the GA API from your app. In this example, the index of the new dimension is 10.

    Repeat this step and create another dimension and call it AppsFlyer Campaign

Step 2: Setting and sending the data from the app

First, you need to get the media source value from AppsFlyer SDK. You can do this using the method onConversionDataSuccess.

Note: Starting SDK V5, onConversionDataSuccess is the name of the method for getting conversion data. If you are using an SDK version lower than 5.0.0, the name of the method is onInstallConversionDataLoaded in Android and onConversionDataReceived in iOS. We recommend that you upgrade to SDK 5.0.0. To learn more, click here.

Then, you can set the media source as custom dimension using Google Analytics SDK. See the following code samples to learn how to do it:

private static Tracker sTracker;
public void onConversionDataSuccess(Map<String, String> conversionData)
  if (conversionData.get("af_status") == "Non-organic")
    String mediaSource = conversionData.get("media_source");
    String campaign = conversionData.get("campaign");
    sTracker.set(Fields.customDimension(10), mediaSource);
    sTracker.set(Fields.customDimension(1), campaign);
  else if (conversionData.get("af_status") == "Organic")
    sTracker.set(Fields.customDimension(10), "Organic");

Step 3: See the results in Google Analytics

Most GA reports have a drill-down option called Custom Dimensions. You can select the dimensions AppsFlyer Media Source or AppsFlyer Campaign (set in step 1) to see which media sources and campaigns bring users that install your app.


Was this article helpful?