-
Couldn't load subscription status.
- Fork 42
Session and Event Callbacks
You can register a callback to be notified of successful and failed tracked events and/or sessions.
Follow the same steps as for attribution callback to implement the following callback function for successfully tracked events:
var adjustConfig = new AdjustConfig(appToken, environment);
adjustConfig.setEventTrackingSucceededCallbackListener(function(eventSuccess) {
// Printing all event success properties.
console.log("Event tracking succeeded!");
console.log(eventSuccess.message);
console.log(eventSuccess.timestamp);
console.log(eventSuccess.eventToken);
console.log(eventSuccess.adid);
console.log(eventSuccess.jsonResponse);
});
Adjust.create(adjustConfig);The following callback function for failed tracked events:
var adjustConfig = new AdjustConfig(appToken, environment);
adjustConfig.setEventTrackingFailedCallbackListener(function(eventFailure) {
// Printing all event failure properties.
console.log("Event tracking failed!");
console.log(eventSuccess.message);
console.log(eventSuccess.timestamp);
console.log(eventSuccess.eventToken);
console.log(eventSuccess.adid);
console.log(eventSuccess.willRetry);
console.log(eventSuccess.jsonResponse);
});
Adjust.create(adjustConfig);For successfully tracked sessions:
var adjustConfig = new AdjustConfig(appToken, environment);
adjustConfig.setSessionTrackingSucceededCallbackListener(function(sessionSuccess) {
// Printing all session success properties.
console.log("Session tracking succeeded!");
console.log(sessionSuccess.message);
console.log(sessionSuccess.timestamp);
console.log(sessionSuccess.adid);
console.log(sessionSuccess.jsonResponse);
});
Adjust.create(adjustConfig);And for failed tracked sessions:
var adjustConfig = new AdjustConfig(appToken, environment);
adjustConfig.setSessionTrackingFailedCallbackListener(function(sessionFailure) {
// Printing all session failure properties.
console.log("Session tracking failed!");
console.log(sessionSuccess.message);
console.log(sessionSuccess.timestamp);
console.log(sessionSuccess.adid);
console.log(sessionSuccess.willRetry);
console.log(sessionSuccess.jsonResponse);
});
Adjust.create(adjustConfig);The callback functions will be called after the SDK tries to send a package to the server. Within the callback you have access to a response data object specifically for the callback. Here is a quick summary of the session response data properties:
-
var messagethe message from the server or the error logged by the SDK. -
var timestamptimestamp from the server. -
var adida unique device identifier provided by adjust. -
var jsonResponsethe JSON object with the response from the server.
Both event response data objects contain:
-
var eventTokenthe event token, if the package tracked was an event.
And both event and session failed objects also contain:
-
var willRetryindicates there will be an attempt to resend the package at a later time.
Basic Integration
Additional Features