Set session callback parameters
Session callback parameters are saved locally and sent with every session and every event the Adtrace SDK records. They are global SDK-level values, not tied to a single AdTraceEvent.
When you add a session parameter, the SDK stores it so you do not need to set it again on each session or track call.
Adding the same session callback parameter key twice has no effect. The first value is kept.
You can call session parameter methods before AdTrace.onCreate() so they are included on the install session. If you need a value for install but can only read it after launch, use Delay SDK start to defer the first session briefly while you attach parameters.
| Session callback parameters | Event callback parameters | |
|---|---|---|
| API | AdTrace.addSessionCallbackParameter(key, value) | event.addCallbackParameter(key, value) |
| Scope | Every session and event | One event |
| When to set | Any time (including before SDK init) | Before AdTrace.trackEvent() |
| Key conflict | Event parameter wins | Takes precedence over session |
If you register a callback URL in the Adtrace panel, session callback parameters are appended to that URL on each session and event, together with any event-level callback parameters.
This page is about callback URL parameters (key-value data sent with sessions and events). For success/failure listeners when the SDK sends packages, see Send callback information.
Add session callback parameters
Method signature
public static void addSessionCallbackParameter(String key, String value)
| Parameter | Type | Description |
|---|---|---|
key | String | The callback parameter name. |
value | String | The callback parameter value. |
The interface matches event callback parameters, but you call it on AdTrace instead of on an AdTraceEvent. Call the method once per key-value pair. You can add multiple parameters by calling it multiple times.
Example
- Java
- Kotlin
- WebBridge
AdTrace.addSessionCallbackParameter("foo", "bar");
AdTrace.addSessionCallbackParameter("foo", "bar")
AdTrace.addSessionCallbackParameter("foo", "bar");
Session callback parameters merge with callback parameters you add to an event. Event callback parameters take precedence: if the same key exists on the session and on an event, the event value is sent.
Remove session callback parameters
Method signature
public static void removeSessionCallbackParameter(String key)
| Parameter | Type | Description |
|---|---|---|
key | String | The session callback parameter key to remove. |
Example
- Java
- Kotlin
- WebBridge
AdTrace.removeSessionCallbackParameter("foo");
AdTrace.removeSessionCallbackParameter("foo")
AdTrace.removeSessionCallbackParameter("foo");
Reset session callback parameters
Method signature
public static void resetSessionCallbackParameters()
Removes all session callback parameter keys and values.
Example
- Java
- Kotlin
- WebBridge
AdTrace.resetSessionCallbackParameters();
AdTrace.resetSessionCallbackParameters()
AdTrace.resetSessionCallbackParameters();
Send session parameters on install
Call addSessionCallbackParameter before AdTrace.onCreate() when the value must be present on the install session:
- Java
- Kotlin
AdTrace.addSessionCallbackParameter("user_segment", "premium");
AdTraceConfig config = new AdTraceConfig(this, appToken, environment);
AdTrace.onCreate(config);
AdTrace.addSessionCallbackParameter("user_segment", "premium")
val config = AdTraceConfig(this, appToken, environment)
AdTrace.onCreate(config)
If the value is not ready at launch, use Delay SDK start instead of initializing immediately.