Skip to main content

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.

Duplicate keys

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 parametersEvent callback parameters
APIAdTrace.addSessionCallbackParameter(key, value)event.addCallbackParameter(key, value)
ScopeEvery session and eventOne event
When to setAny time (including before SDK init)Before AdTrace.trackEvent()
Key conflictEvent parameter winsTakes 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.

Session vs SDK callbacks

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)
ParameterTypeDescription
keyStringThe callback parameter name.
valueStringThe 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

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)
ParameterTypeDescription
keyStringThe session callback parameter key to remove.

Example

AdTrace.removeSessionCallbackParameter("foo");

Reset session callback parameters

Method signature

public static void resetSessionCallbackParameters()

Removes all session callback parameter keys and values.

Example

AdTrace.resetSessionCallbackParameters();

Send session parameters on install

Call addSessionCallbackParameter before AdTrace.onCreate() when the value must be present on the install session:

AdTrace.addSessionCallbackParameter("user_segment", "premium");

AdTraceConfig config = new AdTraceConfig(this, appToken, environment);
AdTrace.onCreate(config);

If the value is not ready at launch, use Delay SDK start instead of initializing immediately.