Have you ever wanted to have a better idea of what’s the best source of your app installs? There’s information around the web on how to do it, but spread out over various sites, so I decided to write this post to consolidate the information.
Starting with Android 1.6, the Android Market’s emits a broadcast Intent named com.android.vending.INSTALL_REFERRER whenever certain parameters are added to the market url. Note that web version of the Market also passes these parameters to your devices upon install. Since the parameters need to follow the Google Analytics referral link format, Google provides a simple tool for generating these urls, or you could use a copy of my shared Google spreadsheet that I use to keep track of all my campaigns. Here’s a description for the important parameters:
|utm_campaign||Used for keyword analysis. Use utm_campaign to identify a specific product promotion or strategic campaign.
|utm_medium||Use utm_medium to identify a medium such as email or cost-per- click.
|utm_source||Use utm_source to identify a search engine, newsletter name, or other source.
So now you have a url with information that is broadcast by the Android Market when your app is installed. The next step is to capture that information inside your app and submit them to your mobile analytics provider (Google Analytics, Flurry, Localytics, etc). The way to do that is to first register a BroadcastReceiver in your AndroidManifest.xml. You’ll need to handle the com.android.vending.INSTALL_REFERRER broadcast like this:
Next we need the implement the class that handles the broadcast. All the class does is receives the INSTALL_REFERRER BroadcastIntent, takes the ‘referrer’ extra from the intent and breaks it down into key/value pairs for submitting it to the analytics package. (AnalyticsTrackerFactory is the Gist is just my generic wrapper for analytics; you can call your own directly instead).
So that’s all there is to it! Just take some vary basic steps and small changes to your app to easily track who’s referring downloads of your app.