Blog / Getting users for your app
Google Play install referrer: track which post brought an install
The Google Play Install Referrer API lets an Android app read the referrer value from the Play Store link used for its install. Put encoded campaign tags in that link. Read the value once after the first launch, save the original text, then parse it. To count installs for one post, give that post its own link. A profile link shared by several posts cannot show which video did the work.
By the USposted team. Published . 6 min read.
The path of one tag, from the link to your table
- Encode
Put three tags inside one referrer value.
- Read
Ask the Play Store for it when the new app first runs.
- Save
Keep the original text and response before parsing.
- Check
Accept only tags from your own list of links.
Play Console can group traffic by UTM source and campaign. The API gives your app the tag for one install, so you can join it to something the person does later, such as finishing the first task. Start by deciding what each link will identify.
Give each post its own link
Suppose ten videos send people to one profile link. Each install carries the same tag, and the API cannot tell which video the person watched. Change the profile tag for each group of posts and report on the group. To report on one post, you need a place where that post has its own link. Our guide on how to add app link to TikTok lists the options.
Use short codes made of lowercase letters, numbers, hyphens and underscores. In this example, the source is "tiktok", the campaign is "budget_demo" and "v014" is the video's row in your content sheet. Put the post's full title and URL in the sheet. They do not belong in the tag.
The tags form a small query string inside the link's own query string. Encode the inner text once when you add it to the link:
https://play.google.com/store/apps/details?id=com.example.app&referrer=utm_source%3Dtiktok%26utm_campaign%3Dbudget_demo%26utm_content%3Dv014
Here, %3D stands for = and %26 stands for &. Let code or Google's URL builder write them, because they are easy to get wrong. Google's guide for Play Games on PC sets a limit of 512 characters for the encoded referrer.[5] We did not find a limit in the phone guides. Keep yours short. Our inner text has 59 characters.
Read the referrer once in the app
The API comes from the Play Store app on the device, which must be version 8.3.73 or later. You also need a Play Console account.[1] Add Google's library to the app's Gradle file:
implementation("com.android.installreferrer:installreferrer:2.2")
Create an InstallReferrerClient and call startConnection(). When the response is OK, read the details with these Kotlin lines from Google's guide:
val response: ReferrerDetails = referrerClient.installReferrer
val referrerUrl: String = response.installReferrer
val referrerClickTime: Long = response.referrerClickTimestampSeconds
val appInstallTime: Long = response.installBeginTimestampSeconds
Save the results, then call endConnection().[2] "Referrer URL" is Google's name for the field. In your code, treat it as text. You do not need a full web address to parse tags.
Google defines the other response codes.[4] Trying again at a later launch is our suggestion:
- SERVICE_DISCONNECTED may be temporary. Google suggests calling startConnection() again.
- SERVICE_UNAVAILABLE means the connection did not start. Save the status and try again at a later launch, up to a limit you choose.
- FEATURE_NOT_SUPPORTED means this Play Store app does not support the API.
- DEVELOPER_ERROR points to incorrect use, so check your code before you try again.
The data is available for 90 days and does not change unless the app is reinstalled.[2] Do not wait until day 90. Read it during the first run, even if you send it to your server later.
Parse the text without guessing
This parser is for Node. Your app sends the original text to your server, and the server runs the code. It accepts normal text. It also accepts text that is still encoded once, which can happen when a link has been encoded twice. It removes at most one extra layer of encoding.
const KEYS = ['utm_source', 'utm_campaign', 'utm_content'];
const SAFE = /^[a-z0-9_-]{1,60}$/;
function parseReferrer(raw) {
if (!raw) return { status: 'empty' };
let text = raw;
if (!text.includes('=') && /%3d/i.test(text)) {
try { text = decodeURIComponent(text); } catch { return { status: 'broken' }; }
}
const query = new URLSearchParams(text);
if (!KEYS.some((key) => query.has(key))) return { status: 'no_utm' };
const tags = {}, bad = [];
for (const key of KEYS) {
const value = query.get(key);
if (value !== null && SAFE.test(value)) tags[key] = value;
else bad.push(key);
}
return { status: bad.length ? 'partial' : 'ok', tags, bad };
}
On November 30, 2026, we ran it in Node 22.13.1 on seven made-up strings. This checks the parser only. We did not install an app from the Play Store, and we did not test Kotlin code.
| Sample | Input | Output |
|---|---|---|
| Normal | utm_source=tiktok&utm_campaign=budget_demo&utm_content=v014 | ok, with all three tags |
| Encoded | utm_source%3Dtiktok%26utm_campaign%3Dbudget_demo%26utm_content%3Dv014 | ok, with the same three tags |
| No UTM | partner=maya | no_utm |
| Missing value | utm_source=tiktok&utm_campaign=&utm_content=v014 | partial, campaign is bad |
| Broken value | utm_source=tiktok&utm_campaign=50%&utm_content=v014 | partial, campaign is bad |
| Encoded and broken | utm_source%3Dtiktok%26utm_campaign%3D50% | broken |
| Empty | An empty string | empty |
Without the try and catch, the bad percent sign in "50%" makes decodeURIComponent() throw "URIError: URI malformed". If you move the parser to Kotlin, run the same seven samples there. Another decoder may handle bad text differently.
Check the mistakes a parser cannot see
We also gave four complete Play links to Node's URL parser, read their referrer values and passed them to our function. This shows how Node reads each link. Google Play may treat a bad link differently.
- The correct link returned "ok" with all three tags.
- With no encoding, the referrer was only "utm_source=tiktok". Node read the other two tags as separate parts of the Play link, so the result was "partial".
- With double encoding, the referrer was still encoded once. Our parser recovered the tags, but other tools may not, so fix the link.
- The campaign name "save&spend" was placed in the inner text before that text was encoded. The result was "ok", but the campaign was only "save".
The last result looks correct but has the wrong campaign. Compare the source, campaign and content code together with one row in your own link list. If they do not match, store "unknown_link". Keep the original text so you can find the error later. This check also stops a made-up campaign from getting its own line in your report. It cannot show that someone used a real code in a fake link.
In JavaScript, pass the tags to URLSearchParams to build the inner text. Then give that text to a second URLSearchParams as the referrer value. The second step encodes the whole text. Our sample link came from this method, and its tags came back unchanged.
Save enough data to explain a result
Make one row for each install you record. Save the original referrer, API response, parser status, matched link, app version and the first useful action. Use your own random install ID so you do not save the same row twice. A reinstall may create another ID, so this is not a count of people.
The lower-level API has click and install times from both the device and the server, and the app version from the first install.[3] Save these names with the source of each time. The time between click and install is useful for checks, but it cannot show that a video caused the install.
For a small example, imagine 40 recorded installs. The API returned a value for 30, and 24 matched a known link. The match rate is 24 ÷ 40 = 60%. These numbers are invented. The other 16 installs are unknown. Do not share them among the known posts. If 12 of the 24 matched installs finished the first task, that group's task rate is 12 ÷ 24 = 50%.
Know what will be missing
If someone sees a video, closes it and later searches the Play Store, they do not use your tagged link. Other installs can be missing because the device does not support the API, the connection fails or the link lost its tags. An install from another store may also leave you without a Play referrer.
Your table will not match every Google report. In Analytics, google-play can mean a referrer link or an organic Play search.[6] In Play Console, small UTM groups can appear under "Other". To see its UTM source, use the ads and referrals filter.[7] Our guide on how to promote an app on Google Play explains its clicks and acquisitions. Report these numbers separately, with their names and dates.
Test the link on a real device
Use a device where the app is not installed. Open the link from the real post or profile, install the app from Google Play and open it. Then compare the saved text with the link. Repeat with a link that has no referrer, and with the device offline at first launch. Check that the app still opens when there is no tag.
Test again after you change the link, landing page or first launch code. If the value also chooses the first screen, read about deferred deep linking. It explains what the app should do when that value never arrives.
Questions people ask
Does the Install Referrer API need an advertising ID or a user permission?
Google's setup guide adds the Play Install Referrer library and a connection to the Play Store app. It has no step for an advertising ID or a runtime permission. The response includes the referrer text, click and install times, and some app details. It does not include a person's name or email. Never put those in your own tags, because you choose the text in the link. If you send the result to a server or an analytics tool, include that in your privacy notice and data review.
Can I read the install referrer every time the app opens?
Google tells you to call the API only once, the first time the app runs after installation. The information stays the same unless the app is reinstalled, so more calls add no new data. Record success only after you have saved the value. If the connection fails, try again later. If you record success before saving, a temporary problem can look like an install without a referrer. A reinstall can return different data, so do not count every saved value as a new person.
Why does Firebase or Google Analytics show a different source?
Google Analytics groups Play Store installs in its own way. Its help page says the source google-play can mean a store link with a referrer or an organic Play search. It uses (direct) for a Play link without a referrer. Your table may instead use your utm_source value, such as tiktok. Compare the definitions and dates before you compare totals. Do not change your saved referrer values to match an Analytics report, because the two systems answer different questions.
Does the install referrer work in Flutter, React Native or Unity?
Google gives two routes. Its client library is for Kotlin and Java, and the lower-level interface is for other languages. In a cross-platform app, you could write a small native bridge or use a maintained plugin. Check the plugin's code, update date and error handling before you use it. Pass the complete referrer text to your own code, as well as any parsed fields. Google also has a separate Unity guide for PC games. Do not copy its settings into an Android build.
Can the install referrer open a specific screen in the app?
Yes, if your app understands a safe value in the text. For example, utm_content could hold a public content ID, and your app could use it to choose the first screen. Check that the ID exists, and have a normal first screen ready when it is missing. The API gives your app text. It does not choose the screen. Never let a link value sign someone in, unlock a purchase or change an account, because anyone can write their own Play link.
Sources
- Android Developers: Google Play Install Referrer
- Android Developers: Play Install Referrer Library
- Android Developers: Play Install Referrer API response fields
- Android Developers: Install referrer response codes
- Android Developers: User acquisition for Google Play Games on PC
- Google Analytics Help: How app key events are attributed
- Google Play Console Help: Understand and grow your app's user base
Prices and platform rules change. We checked these pages on November 30, 2026.





