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 ADTConfig instance before [Adtrace appDidLaunch:] / Adtrace.appDidLaunch(...). 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 or partner devices | Yes |
| Normal App Store or TestFlight 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
- (void)setDefaultTracker:(NSString *)defaultTracker;
You can also assign the defaultTracker property directly on ADTConfig:
@property (nonatomic, copy, nullable) NSString *defaultTracker;
| Parameter | Type | Description |
|---|---|---|
defaultTracker | NSString | 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
setDefaultTracker:on yourADTConfiginstance beforeappDidLaunch. See Configuration for how to create the config. - Build and run your app, then confirm the default tracker in the Xcode console (see Verify the default tracker).
The panel shows a full tracker URL (for example https://app.adtrace.io/abc123). In your code, pass only the token at the end (abc123), not the entire URL.
Example
- Objective-C
- Swift
- Javascript
NSString *appToken = @"{YourAppToken}";
NSString *environment = ADTEnvironmentSandbox;
ADTConfig *adtraceConfig = [ADTConfig configWithAppToken:appToken
environment:environment];
[adtraceConfig setDefaultTracker:@"{TrackerToken}"];
[Adtrace appDidLaunch:adtraceConfig];
Or assign the property:
adtraceConfig.defaultTracker = @"{TrackerToken}";
let appToken = "{YourAppToken}"
let environment = ADTEnvironmentSandbox
let adtraceConfig = ADTConfig(appToken: appToken, environment: environment)
adtraceConfig?.defaultTracker = "{TrackerToken}"
Adtrace.appDidLaunch(adtraceConfig)
let appToken = '{YourAppToken}';
let environment = AdtraceConfig.EnvironmentSandbox;
let adtraceConfig = new AdtraceConfig(appToken, environment);
adtraceConfig.setDefaultTracker('{TrackerToken}');
Adtrace.appDidLaunch(adtraceConfig);
Replace {YourAppToken} with your app token and {TrackerToken} with the tracker token from the panel.
Verify the default tracker
- Set log level to
ADTLogLevelVerboseorADTLogLevelDebugwhile testing. - Build and run your app on a device with the pre-installed build (or your test build with the default tracker configured).
- Open the Xcode console for your running app.
You should see a line like:
Default tracker: 'abc123'
If this line does not appear, check that you called setDefaultTracker before appDidLaunch and that the token matches the tracker in the panel.