Testing Google Play Campaign Measurement

This document describes how to test a Google Play Campaign Measurement
implementation in an Android application before publishing to the Google Play
Store.

Introduction

Google Play Campaign Measurement
is a feature of Google Mobile App Analytics
that enables the attribution of native Android app installs to advertising campaigns and other
marketing efforts in your Google Analytics app reports. Verifying that your Google
Play Campaign Measurement implementation is working properly before the
application is submitted to Google Play ensures that campaign measurement
data is as accurate as possible at the time of launch.

This guide will illustrate one means of testing a Google Play Campaign
Measurement implementation.

Before You Begin

Before using this guide to test a Google Play Campaign Measurement
implementation, you will need the following:

Broadcasting an INSTALL_REFERRER Intent

The next step is to broadcast an INSTALL_REFERRER intent to your application that contains
some Google Analytics campaign data. This is the same intent that the Google Play Store
application broadcasts to your application after it is installed by a user.

Note that the ADB is generally located in your <sdk>/platform-tools/ directory. For example,
if your application package was com.example.gatestapp and you were using the broadcast receiver provided by the
Google Analytics SDK, you would use the following command:

If you do not see this message, the intent has not been broadcast and you will
need to retry this step until you can successfully broadcast the intent.

Verifying the Campaign Data Was Received

The last step in testing is to open the application and verify in the Google Analytics
SDK logs that the campaign information was successfully received. To verify that
the campaign information was received:

Run your application.

If the campaign data was received properly, you can expect to see the SDK print a debug message using logcat similar to this one:

GAv4 : Received installation campaign: source=testSource

If you see this success message in logs, congratulations!
Your Google Play Campaign measurement implementation is working as expected.
Note that you will still want to verify that your Google Play URLs are configured properly using the
Google Play URL Builder.

On the other hand, if your Google Play Campaign Measurement implementation
did not receive the campaign information, you'll see a message similar to this one:

Thread[GAThread,5,main]: No campaign data found.

This means that your Google Play Campaign Measurement implementation is not
working correctly. Check out the Troubleshooting section to
learn about next steps.

Troubleshooting

There are several common reasons for a Google Play Campaign Measurement
test to fail. This section highlights those common points of error and
provides next steps for resolving them.

Debug output is not enabled

The INSTALL_REFERRER intent was not broadcast

In order for the test to succeed, you must successfully broadcast an INSTALL_REFERRER
intent to your application from the Android Debug Bridge.
If you're not sure that the intent was broadcast successfully, return to
the Broadcast section of this guide and rerun the
test, verifying that you used the correct command and are seeing the
broadcast success message returned.

The Google Analytics Receiver did not receive the intent

The Google Analytics SDK provides a receiver, CampaignTrackingReceiver,
that must receive the INSTALL_REFERRER in order for any campaign
data to be passed from Google Play to your Google Analytics reports. If the
CampaignTrackingReceiver never receives the intent, the campaign
data will not be recorded in Google Analytics. There are two main reasons
the CampaignTrackingReceiver may not be receiving the intent:

The CampaignTrackingReceiver is implemented, but another
receiver is receiving the INSTALL_REFERRER instead. This happens
when an application has more than one broadcast receiver registered to handle
the INSTALL_REFERRER intent.

If your application has two receivers registered for this intent,
it is recommended that you create a custom receiver that can receive the
INSTALL_REFERRER intent and dispatch it to other receivers, including
the Google Analytics receiver, as necessary. Here's an example of a simple
receiver to accomplish this: