adjust-icon

Set up callbacks

Set up callbacks to trigger functions when the SDK sends information to Adjust. You can set up callbacks for sessions and events.

Session callbacks

Set up session callbacks to trigger functions when the SDK sends session information. You can create success callbacks and failure callbacks. Success callbacks trigger when the SDK sends information to Adjust’s servers. Failure callbacks trigger when the SDK encounters a problem while sending the information.

Session callbacks have access to a response data object. You can use its properties in your callback function.

PropertyData typeDescription
MessagestringThe message from the server or the error logged by the SDK.
TimestampstringThe timestamp from Adjust’s servers.
AdidstringA unique device identifier provided by Adjust.
JsonResponseDictionary<string, object>The JSON object with the response from the server.
WillRetryboolIndicates whether there will be an attempt to resend a failed package.

Success callbacks

Property declaration
public Action<AdjustSessionSuccess> SessionSuccessDelegate { get; set; }

Set up success callbacks to trigger functions when the SDK records a session.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.SessionSuccessDelegate = SessionSuccessCallback;
//...
Adjust.InitSdk(adjustConfig);
//...
public void SessionSuccessCallback (AdjustSessionSuccess sessionSuccessData) {
//...
}

Example

This example shows how to create a callback function SessionSuccess and register it as a success callback. The function logs the timestamp at which the SDK recorded the session.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.SessionSuccessDelegate = SessionSuccess;
// ...
Adjust.InitSdk(adjustConfig);
// ...
public void SessionSuccess (AdjustSessionSuccess sessionSuccessData) {
Debug.Log("Session recorded at " + sessionSuccessData.Timestamp);
}

Failure callbacks

Property declaration
public Action<AdjustSessionFailure> SessionFailureDelegate { get; set; }

Set up failure callbacks to trigger functions when the SDK fails to record a session.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.SessionFailureDelegate = SessionFailureCallback;
//...
Adjust.InitSdk(adjustConfig);
//...
public void SessionFailureCallback (AdjustSessionFailure sessionFailureData) {
//...
}

Example

This example shows how to create a callback function SessionFailure and register it as a failure callback. The function logs the session failure message.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.SessionFailureDelegate = SessionFailure;
// ...
Adjust.InitSdk(adjustConfig);
// ...
public void SessionFailure (AdjustSessionFailure sessionFailureData) {
Debug.Log("Session recording failed. Response: " + sessionFailureData.Message);
}

Event callbacks

Set up event callbacks to trigger functions when the SDK sends event information. You can create success callbacks and failure callbacks. Success callbacks trigger when the SDK sends information to Adjust’s servers. Failure callbacks trigger when the SDK encounters a problem while sending the information.

Event callbacks have access to a response data object. You can use its properties in your callback function.

PropertyData typeDescription
MessagestringThe message from the server or the error logged by the SDK.
TimestampstringThe timestamp from Adjust’s servers.
AdidstringA unique device identifier provided by Adjust.
JsonResponseDictionary<string, object>The JSON object with the response from the server.
EventTokenstringThe event token
CallbackIdstringThe custom callback ID set on the event object
WillRetryboolIndicates whether there will be an attempt to resend a failed package.

Success callbacks

Property declaration
public Action<AdjustEventSuccess> EventSuccessDelegate { get; set; }

Set up success callbacks to trigger functions when the SDK records an event.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.EventSuccessDelegate = EventSuccessCallback;
//...
Adjust.InitSdk(adjustConfig);
//...
public void EventSuccessCallback(AdjustEventSuccess eventSuccessData) {
//...
}

Example

This example shows how to create a callback function EventSuccess and register it as a success callback. The function logs the timestamp at which the SDK recorded the event.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.EventSuccessDelegate = EventSuccess;
// ...
Adjust.InitSdk(adjustConfig);
// ...
public void EventSuccess (AdjustEventSuccess eventSuccessData) {
Debug.Log("Event recorded at " + eventSuccessData.Timestamp);
}

Failure callbacks

Property declaration
public Action<AdjustEventFailure> EventFailureDelegate { get; set; }

Set up failure callbacks to trigger functions when the SDK fails to record an event.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.EventFailureDelegate = EventFailureCallback;
//...
Adjust.InitSdk(adjustConfig);
//...
public void EventFailureCallback(AdjustEventFailure eventFailureData) {
//...
}

Example

This example shows how to create a callback function EventFailure and register it as a failure callback. The function logs the event failure message.

AdjustConfig adjustConfig = new AdjustConfig("{Your App Token}", AdjustEnvironment.Sandbox);
adjustConfig.LogLevel = AdjustLogLevel.Verbose;
adjustConfig.EventFailureDelegate = EventFailure;
// ...
Adjust.InitSdk(adjustConfig);
// ...
public void EventFailure (AdjustEventFailure eventFailureData) {
Debug.Log("Event recording failed. Response: " + eventFailureData.Message);
}