So you are building a new React Native app and you plan to provide download links with many different ways (social media, email campaigns, blog posts etc) as part of your marketing process. Next, you want to evaluate which of these links worked better and converted to actual downloads. This what Google UTM parameters do and can help you with tracking and measuring.

Google UTM parameters are simply tags that you add to a URL. When someone clicks on a URL with UTM parameters, those tags are sent back to your Google Analytics account for tracking. When it comes to mobile apps, we are interested to receive these when a user installs our app.

This article will focus on how to configure your React Native app to achieve that. If you want to know more about UTM tags and how they work you can check out the How To Use UTM Parameters In Google Analytics 5 article of Kissmetrics blog and/or What are UTM codes article of launchdigitalmarketing.com website.

Image 1: Google UTM tags can prove useful for tracking installation referrals

How to configure UTM parameters

Get a Google Analytics account

The first thing we need, is to have a Google Analytics account. Either create a new or use you existing one and create an app under this account in order to get an ID.

Image 2: Example setup as implemented for Math Warriors Android game.

Install Google Analytics in your RN app

Since Google UTM codes tracking is part of Google Analytics and since we plan to track installations, we do need to install them over our application. The best way I have found to do this currently, is through react-native-google-analytics-bridge. It’s not an official Google package, but instead a community-built, React Native bridge to the Google Analytics libraries of both iOS and Android.

Installation is fairly simple but it since it is a bridged package, you will have to link with native binaries as well.

Android Manifest — The not so obvious configuration

And now, we need to make the application be able to receive installation information and dispatch the UTM info to Analytics. To achieve that, we add the following xml code inside the AndroidManifest.xml file and inside the application element:

<!-- Enable background dispatching to improve delivery on non-Google Play devices -->

<receiver

android:name="com.google.android.gms.analytics.AnalyticsReceiver"

android:enabled="true"

android:exported="true">

<intent-filter>

<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>

</intent-filter>

</receiver>

<service

android:name="com.google.android.gms.analytics.AnalyticsService"

android:enabled="true"

android:exported="true" />

<!-- Enable Google Play Store Campaign reports -->

<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"

android:enabled="true"

android:exported="true">

<intent-filter>

<action android:name="com.android.vending.INSTALL_REFERRER"/>

</intent-filter>

</receiver>

<service android:name="com.google.android.gms.analytics.CampaignTrackingService"

android:enabled="true"

android:exported="true" />

To make this a bit more visibly clearer let’s see a real example:

Image 3: AndroidManifest.xml in release mode of Math Warriors Android app

I suggest to configure this only for release mode and not for development in order to track production statistics and not development as well. If you want to check how to create a separate AndroidManifest.xml file for production (release) mode, have a look at my previous article How to Remove unnecessary Android permissions from React Native apps.

Test your referral tracking configured setup

We are finished setting up the configuration, but in order to be sure it works, we need to run some tests the right way. Tests take place on 2 levels: command line terminal and Google Analytics reports.

Command line terminal

The easiest way is through adb tool. Just run in a terminal:

adb shell

am broadcast -a com.android.vending.INSTALL_REFERRER -n <your.package>/.<path.up.until.your.BroadcastReceiver> --es "referrer" "utm_source=test_source\&utm_medium=test_medium\&utm_term=test_term\&utm_content=test_content\&utm_campaign=test_name"

I.e.

adb shell

am broadcast -a com.android.vending.INSTALL_REFERRER -n com.wizope.mathwarriorsgame/com.google.android.gms.analytics.CampaignTrackingService --es "referrer" "utm_source%3Dmedium%26utm_medium%3Dblog%26utm_content%3Dreactnativepost%26utm_campaign%3Dreactnativepost"

Now after running this command and if you don’t see any error tracking should work fine. Final confirmation will be given through Google Analytics.

Google Analytics reporting

Now start monitoring your downloads through Acquisition -> Sources menu entries. Do your test downloads appear?

Image 4: Download sources list with UTM referral codes of Math Warriors Android app

Image 5: Download sources list with UTM referral codes of Math Warriors Android app

What do you think?

What do you think about UTM codes? Feel free to offer your perspective and ideas to the comments section below.

Do you have a specific subject that you would like me to cover? If I have worked on it, I will be more than happy to share my perspective.