Default tracker
Use a default tracker when your app is pre-installed on a device. The first time a user opens that pre-installed app, Adtrace attributes the install to the tracker you set.
This is a read-only setting: call setDefaultTracker on your AdTraceConfig instance before AdTrace.onCreate(). You cannot change it after the SDK starts.
When to use a default tracker
| Use case | Set a default tracker? |
|---|---|
| App shipped pre-installed on OEM / partner devices | Yes |
| Normal Play Store or direct-download installs with campaign links | No, use your tracker URLs as usual |
| Override organic attribution for unattributed users | No, default tracker is for pre-install flows only |
Method signature
public void setDefaultTracker(String defaultTracker)
| Parameter | Type | Description |
|---|---|---|
defaultTracker | String | The Adtrace tracker token for pre-installed installs. Pass only the token (for example abc123), not the full tracker URL. The value is case-sensitive. |
Set a default tracker
- Create a new tracker in the Adtrace panel. Use this tracker to measure pre-installed installs.
- Call
setDefaultTrackeron yourAdTraceConfiginstance beforeAdTrace.onCreate(). See Configuration for how to create the config. - Build and run your app, then confirm the default tracker in LogCat (see Verify the default tracker).
The panel shows a full tracker URL (for example http://app.adtrace.io/abc123). In your code, pass only the token at the end (abc123), not the entire URL.
Example
- Java
- Kotlin
- Javascript
config.setDefaultTracker("{TrackerToken}");
config.setDefaultTracker("{TrackerToken}")
config.setDefaultTracker("{TrackerToken}");
Replace {TrackerToken} with the tracker token from the panel.
Verify the default tracker
- Set log level to
VERBOSEorDEBUGwhile testing. - Build and run your app on a device with the pre-installed build (or your test build with the default tracker configured).
- Filter LogCat with the
AdTracetag.
You should see a line like:
LogCat (example)
Default tracker: 'abc123'
If this line does not appear, check that you called setDefaultTracker before AdTrace.onCreate() and that the token matches the tracker in the panel.