Campaign Measurement

This document provides an overview of how to measure campaigns and traffic sources with the Google Analytics SDK v4 for Android.


Measuring campaigns in Google Analytics enables the attribution of campaigns and traffic sources to user activity within your application. These options are available for campaign and traffic source attribution in the Google Analytics SDK v4 for Android:

The following sections will describe when and how to implement each type of campaign measurement in your app.

Google Play Campaign Attribution

Google Play Campaign Measurement allows you to see which campaigns and traffic sources are sending users to download your app from the Google Play Store. It is recommended that all developers implement Google Play Store Campaign Measurement.

Implementing Google Play Campaign Attribution

When your app is downloaded from Google Play Store, the Play Store app broadcasts an INSTALL_REFERRER intent to your app during installation. This intent contains the value of the referrer parameter of the link used to reach your app's Google Play Store page, if one was present.

To attribute an app download to a campaign, you must add a referrer parameter to any links that point to Google Play Store, and add a BroadcastReceiver to your app to receive and set the campaign information contained in the intent on your Google Analytics tracker.

It is recommended that most developers use the BroadcastReceiver provided with the SDK. To implement Google Play Store Campaign Measurement using the included receiver:

1. Add the Google Analytics receiver to your AndroidManifest.xml file. To add the Google Analytics receiver to the manifest, copy and paste the following markup:

    <!-- Used for Google Play Store Campaign Measurement-->
    <receiver android:name=""
            <action android:name="" />
    <service android:name=""
        android:exported="false" />

2. Add Google Analytics Campaign Parameters to Google Play URLs

Next, add a referrer parameter to any URLs that will be linking directly to Google Play Store and set the value of that parameter to a string of Google Analytics campaign parameters that describe the source, as in this example:

To learn how to build a campaign parameter strings, use the Google Play URL Builder, or consult the Campaign Parameters reference section.

Testing Google Play Campaign Attribution

To verify that your Google Play Campaign Measurement implementation is working as expected before publishing your app, use the Testing Google Play Campaign Attribution Solution Guide.

General Campaign & Traffic Source Attribution

After an app has been installed, it may be launched by referrals from ad campaigns, websites, or other apps. In this scenario, referring traffic sources or marketing campaigns may be attributed to user activity in subsequent sessions by setting the campaign parameters on a tracker directly by using the setCampaignParamsFromUrl method.

// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(

// Set screen name.

// In this example, campaign information is set using
// a url string with Google Analytics campaign parameters.
// Note: This is for illustrative purposes. In most cases campaign
//       information would come from an incoming Intent.
String campaignData = "" +
    "utm_source=email&utm_medium=email_marketing&utm_campaign=summer" +

// Campaign data sent with this hit.
t.send(new HitBuilders.ScreenViewBuilder()

See Advanced Configuration for details on the getTracker method.

Campaign Parameters

Campaign parameters are used to pass information about the traffic sources and campaigns that are bringing users to your app.

The table below contains the available campaign parameters that can be used in Google Play or general campaign measurement:

Parameter Description Example(s)
utm_source Campaign source; used to identify a search engine, newsletter, or other source utm_source=google
utm_medium Campaign medium; used to identify a medium such as email or cost-per-click (cpc) utm_medium=cpc
utm_term Campaign term; used with paid search to supply the keywords for ads utm_term=running+shoes
utm_content Campaign content; used for A/B testing and content-targeted ads to differentiate ads or links that point to the same URL utm_content=logolink
utm_campaign Campaign name; used for keyword analysis to identify a specific product promotion or strategic campaign utm_campaign=spring_sale
gclid Google Ads autotagging parameter; used to measure ads. This value is generated dynamically and should never be modified.

Google Play URL Builder

Use the tool below to generate URLs for Google Play Campaign Measurement.