If your app is pre-installed on a device, you need to use a pre-install link to attribute users. The Adjust Store & Pre-Install Tool (adjust-dtt) enables you to insert this information into your APK. The Adjust SDK reads the information inserted by adjust-dtt. This enables you to attribute users of pre-installed apps to specific Adjust links.
Before you begin
To get started, download the adjust-dtt tool from GitHub. You need to make this file executable to use it. Run the following command to make the file executable:
$ chmod +x adjust-dttBefore you can use adjust-dtt, you need to set up your machine. adjust-dtt requires the following tools to be installed on your device:
ruby: the language tools used to runadjust-dtt.apktool: a tool for unpacking and re-packing APKs.jarsigner: a tool for signing APKs.
Follow these instructions to install each one.
Ruby
Apktool
Jarsigner
Add preinstall link information
Step 1. Get keystore file
When you create an APK, Android Studio will sign it. This happens even if you have generated an “unsigned” version of the APK. When you do this, Android Studio signs the APK with a default debug signing keystore file. This keystore file is located at ~/.android/debug.keystore by default.
If you export a signed APK from Android Studio, you will sign the APK with your custom signing keystore file.
To use adjust-dtt you need to have access to either the default keystore file or your custom one. This is because apktool removes all signing when you use it to unpack the APK. Once you repackage the APK, signing isn’t re-enabled. You need to run jarsigner with your signing information to re-sign the APK to deliver it to Android devices.
Step 2. Create link
Next, you need to create a link in your Adjust dashboard. You will use the link token as the default campaign for your pre-installed app. This means that all users who have the app pre-installed will be attributed to this token.
Step 3. Create a config file
Once you have your keystore file and your link token, you can create a configuration file. adjust-dtt uses an adjust-config.yaml configuration file to read your settings. This file includes settings for the different app stores you need to set up.
| Parameter | Data type | Global or per-store | Description |
|---|---|---|---|
apk_path | String | Both | The absolute path to your APK. |
keystore_path | String | Both | The absolute path to your keystore file. |
keystore_pass | String | Both | Your keystore signing password. |
keystore_alias | String | Both | Your keystore alias. |
default_tracker | String | Per-store | The Adjust link token to attribute pre-installs to. |
Here’s an example adjust-config.yaml file including settings for three stores named store_1, store_2, and store_3.
apk_path: /Users/username/Desktop/apk/example-release.apkkeystore_path: /Users/username/Desktop/apk/mykeystore.jkskeystore_pass: mykeystorepasskeystore_alias: mykeystorealiasstores: store_1: default_tracker: abc123 store_2: default_tracker: abc456 store_3: default_tracker: abc789You can define global parameters in the root of the file if you want to use the same settings for each store. Parameters set on a store will override the global parameters for that store. For example:
apk_path: /Users/username/Desktop/apk/example-release.apkkeystore_path: /Users/username/Desktop/apk/mykeystore.jkskeystore_pass: mykeystorepasskeystore_alias: mykeystorealiasstores: store_1: default_tracker: abc123 keystore_path: /Users/username/Desktop/apk/differentkeystore.jks keystore_pass: differentkeystorepass keystore_alias: differentkeystorealias store_2: default_tracker: abc456 store_3: default_tracker: abc789In this example, the adjust-dtt tool uses differentkeystore.jks, differentkeystorepass and differentkeystorealias when generating the APK for store_1. The tool generates a modified APK for each store.
Step 4. Run the adjust-dtt tool
The adjust-dtt tool takes the path to the your adjust-config.yaml file as an argument. To add your campaign information to your APK, run the tool like this:
$ adjust-dtt adjust-config.yamladjust-dtt does the following:
- Unpacks your APK into a folder. The folder will be located in the same directory as your APK. It will have the same name as your APK.
- Searches for an
assetsfolder and anadjust_config.propertiesfile. Theadjust_config.propertiesfile contains default campaign information.- Creates the
assetsfolder andadjust_config.propertiesfile if they don’t exist. The tool writes yourdefault_trackerinformation to theadjust_config.propertiesfile. - Writes the
default_trackerinformation to theadjust_config.propertiesfile if it exists. If the file already contains a default campaign value, it compares the two. If they differ, the value in youradjust-config.yamlfile overwrites the existing value.
- Creates the
- Repackages the APK.
- Signs the APK with the information specified in the
adjust-config.yaml. It uses thekeystore_path,keystore_pass, andkeystore_aliasparameters. - Generates an APK with the same name as the original with a
_[store_name]suffix. In the above example, the tool generates three APK files. These would be namedexample-release_store_1.apk,example-release_store_2.apkandexample-release_store_3.apk. Once the tool has generated these files, you can rename them.
If you have any questions or issues with this tool, contact support@adjust.com.