Requirements
- Android 5.0 (API level 21) or higher
- Android Studio Flamingo (2022.2.1) or newer
- Gradle 8.0+
Installation
Step 1: Gradle Setup
Add the Linkrunner SDK to your app’sbuild.gradle file:
settings.gradle file:
Step 2: Required Permissions
Add the following permissions to yourAndroidManifest.xml file:
Note: TheAD_IDpermission (<uses-permission android:name="com.google.android.gms.permission.AD_ID" />) is already included in the SDK and is required for collecting device identifiers (GAID). If your app participates in Designed for Families, you should revoke AAID and disable AAID collection. See the Disabling AAID Collection section for more details.
Step 3: Backup Configuration
The SDK provides backup rules to exclude Shared Preferences data from backup. This prevents the retention of the Linkrunner install ID during reinstallation, ensuring accurate detection of new installs and re-installs.This backup configuration works similarly for all SDKs (React Native, Flutter,
and native Android). The same Android backup rules apply regardless of which
SDK you’re using.
Adding Backup Rules to Your App
Add to yourAndroidManifest.xml:
android:fullBackupContent- Used for Android 6-11android:dataExtractionRules- Used for Android 12+
Merging Backup Rules
If you already have your own backup rules specified (e.g.,android:fullBackupContent="@xml/my_backup_descriptor" or android:dataExtractionRules="@xml/my_rules"), then manually add the following rules to your existing files:
For legacy backup (Android 6-11) in res/xml/my_backup_descriptor:
res/xml/my_backup_rules.xml:
Step 4: Revoking the AD_ID Permission (Optional)
According to Google’s Policy, apps that target children must not transmit the Advertising ID. To revoke the AD_ID permission, use SDK version 3.5.0 and above. Children apps targeting Android 13 (API 33) and above must prevent the permission from getting merged into their app by adding a revoke declaration to their Manifest. Use thesetDisableAaidCollection() and isAaidCollectionDisabled() functions to disable AAID collection programmatically:
AndroidManifest.xml
Make sure to add
xmlns:tools="http://schemas.android.com/tools" to your manifest tag to use the tools:node="remove" attribute. If you disable AAID collection, you should also remove the AD_ID permission from your manifest to fully comply with Google Play’s Family Policy requirements.Importing in Kotlin/Java
After installation, you can import the SDK in your Kotlin or Java files:Initialization
Initialize the Linkrunner SDK in your application, typically in yourApplication class or main activity:
You can find your project token here.
Note: This method returns a void. To get attribution data and deeplink information, use the getAttributionData method.
SDK Signing Parameters (Optional)
For enhanced security, the LinkRunner SDK requires the following signing parameters during initialization:secretKey: A unique secret key used for request signing and authenticationkeyId: A unique identifier for the key pair used in the signing processdebug(optional): Boolean flag to enable debug mode for development (defaults to false)
User Registration
Call thesignup method once after the user has completed your app’s onboarding process:
It is strongly recommended to use the integrated platform’s identify function to set a persistent user_id once it becomes available (typically after signup or login).
- Mixpanel - ID Management & User Identification
- PostHog - How User Identification Works
- Amplitude - Identify Users Documentation
- mixpanelDistinctId for Mixpanel
- posthogDistinctId for PostHog
- amplitudeDeviceId for Amplitude
Getting Attribution Data
To get attribution data and deeplink information for the current installation, use thegetAttributionData function:
Setting User Data
CallsetUserData each time the app opens and the user is logged in:
Setting CleverTap ID
Use thesetAdditionalData method to set CleverTap ID:
Revenue Tracking
Revenue data is only stored and displayed for attributed users. Make sure you have implemented the
.signup function before capturing payments. To attribute a test user, follow the Integration Testing guide. You can verify your events are being captured on the Events Settings page.Capturing Payments
Track payment information with the following details:Available Payment Types
| Type | Description |
|---|---|
FIRST_PAYMENT | User’s first payment |
SECOND_PAYMENT | User’s second payment |
WALLET_TOPUP | Adding funds to wallet |
FUNDS_WITHDRAWAL | Withdrawing funds |
SUBSCRIPTION_CREATED | New subscription created |
SUBSCRIPTION_RENEWED | Subscription renewal |
ONE_TIME | One-time payment |
RECURRING | Recurring payment |
DEFAULT | Default payment type |
Available Payment Statuses
| Status | Description |
|---|---|
PAYMENT_INITIATED | Payment process started |
PAYMENT_COMPLETED | Payment successfully completed |
PAYMENT_FAILED | Payment failed |
PAYMENT_CANCELLED | Payment was cancelled |
Removing Payments
To remove or refund a payment:Tracking Custom Events
Events are only stored and displayed for attributed users. Make sure you have implemented the
.signup function before tracking events. To attribute a test user, follow the Integration Testing guide. You can verify your events are being captured on the Events Settings page. For capturing revenue, it is recommended to use the .capturePayment method instead of .trackEvent.Revenue Sharing with Ad Networks
To enable revenue sharing with ad networks like Google Ads and Meta, include anamount parameter as a number in your custom event data. This allows the ad networks to optimize campaigns based on the revenue value of conversions:
For revenue sharing with ad networks to work properly, ensure the
amount parameter is passed as a number (Double
or Int), not as a string.Ecommerce Events
Minimum SDK Version: Ecommerce Event Manager requires linkrunner-android v3.6.0 or above. Please ensure your SDK is updated before using this feature.
If you are tracking Ecommerce events to sync with Meta Catalog Sales, you must format your eventData to include Meta’s required fields. You also need to map your custom event to the standard commerce event in the Linkrunner Dashboard.
For detailed explanations of the required fields like content_ids, contents, and value, refer to our Meta Commerce Manager documentation.
Add To Cart Example
Use thetrackEvent method to send an AddToCart event:
View Content Example
Use thetrackEvent method to send a ViewContent event:
Payment / Purchase Example
Use thecapturePayment method to send a Purchase event containing the ecommerce payload:
Note: For more information on testing and verifying your ecommerce events, please see our Testing Ecommerce Events guide.
Enhanced Privacy Controls
The SDK offers options to enhance user privacy:Disabling AAID Collection
SDK Version Requirement: The AAID collection disable functionality
requires Android SDK version 3.5.0 or higher.
Disable AAID Collection
To disable AAID collection, callsetDisableAaidCollection before SDK initialization:
Removing AD_ID Permission
If you want to completely remove theAD_ID permission from your app’s manifest (for example, for apps targeting children), you can override the SDK’s permission declaration in your AndroidManifest.xml. For detailed instructions on revoking the AD_ID permission, including Google’s policy requirements for apps targeting children and Android 13+ (API 33+), see the Revoking the AD_ID Permission section above.
Uninstall Tracking
Before you begin
Here’s what you need to know before getting started: Requirements:- Android SDK 3.2.1 and later
- Firebase Cloud Messaging in your Android project
Android
Connect Firebase Cloud Messaging (FCM) with LinkrunnerFCM HTTP v1 API
FCM HTTP v1 API
To configure FCM HTTP V1 for uninstalls:Enable the FCM API:
- Go to the FCM console.
- Select a project.
- Go to Project Overview > Project settings.
- Copy the Project ID. This will be required in a later step.

- Go to the Cloud Messaging tab.
- Make sure that Firebase Cloud Messaging API (V1) is set to Enabled.
- Go to the Service accounts tab.
- Click Manage service account permissions.
- A new browser tab opens in Google Cloud Platform.
- In the side menu, select Roles.
- Click + Create role.
- Enter the following details:
- Title: Linkrunner Uninstalls
- ID: lr_uninstalls
- Role launch stage: General availability
- Click + Add permissions.
- In Enter property name or value field, enter
cloudmessaging.messages.createand select it from the search results.
- Check the cloudmessaging.messages.create option and click Add.
- Click Create.
- In the side menu, select IAM.
- Open the View by Principals tab.
- Click Grant Access.
- In Add Principals -> New principals field, enter
lr-uninstalls-tracking@lr-uninstalls-tracking.iam.gserviceaccount.com - In Assign Roles -> Select a role field, enter
Linkrunner Uninstallsand select it from the search results. - Click Save.
Linkrunner Dashboard
Linkrunner Dashboard
- In Linkrunner, go to Settings > Uninstall Tracking.
-
Under the Android tab, enter the Firebase Project ID that you copied initially and click Save.

Integrate with Linkrunner SDK
Integrate with Linkrunner SDK
Follow these instructions to integrate FCM with the Linkrunner SDK:Don’t forget to register your service in Custom implementations of FCM’s
- Set up Firebase Cloud Messaging:
- Configure your app to provide the device’s push token to the Linkrunner SDK.
AndroidManifest.xml:onMessageReceived method can unintentionally make uninstall push notifications visible to users, disrupting the intended silent experience. To avoid this, ensure your logic checks if the message contains lr-uninstall-tracking and handles it accordingly, as shown in the code example above.Function Placement Guide
| Function | Where to Place | When to Call |
|---|---|---|
LinkRunner.getInstance().init | Application class | Once when app starts |
LinkRunner.getInstance().getAttributionData | Attribution data handling flow | Whenever the attribution data is needed |
LinkRunner.getInstance().setAdditionalData | Integration code | When third-party integration IDs are available |
LinkRunner.getInstance().signup | Onboarding flow | Once after user completes onboarding |
LinkRunner.getInstance().setUserData | Authentication logic | Every time app opens with logged-in user |
LinkRunner.getInstance().trackEvent | Throughout app | When specific user actions occur |
LinkRunner.getInstance().capturePayment | Payment processing | When user makes a payment |
LinkRunner.getInstance().removePayment | Refund flow | When payment needs to be removed |
LinkRunner.getInstance().setPushToken | Push notification setup | When FCM token is available |
LinkRunner.getInstance().setDisableAaidCollection | App initialization or privacy settings | When you need to disable AAID collection |
LinkRunner.getInstance().isAaidCollectionDisabled | Privacy settings or compliance checks | When you need to check AAID collection status |
Complete Example
Here’s a simplified example showing how to integrate Linkrunner in a native Android app: You can find your project token here.Next Steps
Test Your Integration
Validate your setup end-to-end
Set Up Deep Linking
Configure deep links for your app