The Adjust SDK provides an ADJEvent
object which can be used to structure and send event information from your app to Adjust’s servers.
Instantiate an ADJEvent object
+ (nullable ADJEvent * )eventWithEventToken:(nonnull NSString * )eventToken;
To send event information with the Adjust SDK, you need to instantiate an ADJEvent
object. This object contains variables that are sent to Adjust when an event occurs in your app.
To instantiate an event object, create a new ADJEvent
instance and pass the following parameters:
let event = ADJEvent ( eventToken : "abc123" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent ( "abc123" );
Adjust. trackEvent (adjustEvent);
Send an event
+ ( void )trackEvent:(nullable ADJEvent * )event;
You can associate your Adjust event tokens to actions in your app to record them. To record an event:
Create a new Adjust event instance and pass your event token as a string argument.
Call the trackEvent
method with your event instance as an argument.
let event = ADJEvent ( eventToken : "abc123" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent ( "abc123" );
Adjust. trackEvent (adjustEvent);
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button.
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventSimple: UIButton ?
@IBAction func btnRecordEventSimple ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordDeduplicatedEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordSimpleEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordDeduplicatedEvent = document. getElementById ( 'btnRecordDeduplicatedEvent' )
btnRecordDeduplicatedEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' )
Adjust. trackEvent (adjustEvent)
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordDeduplicatedEvent" >Record simple event</ button >
callback_params {"key":"value","foo":"bar"}
created_at 2024-01-25T14:13:16.151Z+0100
device_manufacturer Apple
event_buffering_enabled 0
hardware_name UE1A.230829.036
package_name com.adjust.examples
partner_params {"key":"value","foo":"bar"}
Record event revenue
- ( void )setRevenue:( double )amount currency:(nonnull NSString * )currency;
You can record revenue associated with an event by setting the revenue and currency properties on your event instance. Use this feature to record revenue-generating actions in your app.
To set these properties, call the setRevenue
method and pass the following arguments:
revenue
(double
): The amount of revenue generated by the event
currency
(NSString
): The ISO 4217 code of the event currency.
let event = ADJEvent ( eventToken : "abc123" )
event ? . setRevenue ( 0.01 , currency : "EUR" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[event setRevenue:0.01 currency: @"EUR" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent (eventToken);
adjustEvent. setRevenue ( 0.01 , "EUR" );
Adjust. trackEvent (adjustEvent);
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button. The function sets the revenue
property of this event to 0.25
and the currency
property to EUR
.
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventRevenue: UIButton ?
@IBAction func btnRecordEventRevenue ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
event ? . setRevenue ( 0.25 , currency : "EUR" );
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordRevenueEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordRevenueEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[event setRevenue:0.25 currency: @"EUR" ];
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordRevenueEvent = document. getElementById ( 'btnRecordRevenueEvent' )
btnRecordRevenueEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' )
adjustEvent. setRevenue ( 0.25 , 'EUR' )
Adjust. trackEvent (adjustEvent)
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordRevenueEvent" >Record revenue event</ button >
Deduplicate revenue events
- ( void )setTransactionId:(nonnull NSString * )transactionId;
You can pass an optional identifier to avoid recording duplicate events. The SDK stores the last ten identifiers and skips revenue events with duplicate transaction IDs.
To set the identifier, assign your transaction ID to the setTransactionId
property of your event instance.
let event = ADJEvent ( eventToken : "abc123" )
event ? . setTransactionId (transaction.transactionIdentifier)
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[event setTransactionId: transaction.transactionIdentifier];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent (eventToken);
adjustEvent. setTransactionId (orderId);
Adjust. trackEvent (adjustEvent);
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button. The function sets the uniqueId
to 5e85484b-1ebc-4141-aab7-25b869e54c49
using the setTransactionId
method.
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventSimple: UIButton ?
@IBAction func btnRecordEventSimple ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
event. setTransactionId ( "5e85484b-1ebc-4141-aab7-25b869e54c49" )
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordDeduplicatedEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordSimpleEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[event setTransactionId: @"5e85484b-1ebc-4141-aab7-25b869e54c49" ]
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordDeduplicatedEvent = document. getElementById ( 'btnRecordDeduplicatedEvent' )
btnRecordDeduplicatedEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' )
adjustEvent. setTransactionId ( "5e85484b-1ebc-4141-aab7-25b869e54c49" )
Adjust. trackEvent (adjustEvent)
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordDeduplicatedEvent" >
transaction_id 5e85484b-1ebc-4141-aab7-25b869e54c49
Add callback parameters
- ( void )addCallbackParameter:(nonnull NSString * )key value:(nonnull NSString * )value;
If you register a callback URL in the Adjust dashboard, the SDK sends a GET request to your callback URL when it records an event.
You can configure callback parameters to send to your servers. Once you configure parameters on an event, the SDK appends them to your callback URL . You can use this information to analyze your users’ in-app behavior with your BI system.
Add callback parameters to your event by calling the addCallbackParameter
method with NSString
key-value arguments. You can add multiple parameters by calling this method multiple times.
let event = ADJEvent ( eventToken : "abc123" )
event ? . addCallbackParameter ( "key" , value : "value" )
event ? . addCallbackParameter ( "foo" , value : "bar" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[event addCallbackParameter: @"key" value: @"value" ];
[event addCallbackParameter: @"foo" value: @"bar" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent (eventToken);
adjustEvent. addCallbackParameter ( "key" , "value" );
adjustEvent. addCallbackParameter ( "foo" , "bar" );
Adjust. trackEvent (adjustEvent);
The Adjust SDK measures the event and sends a request to your URL with the callback parameters. For example, if you register the URL https://www.mydomain.com/callback
, your callback looks like this:
https://www.mydomain.com/callback?key=value&foo=bar
If you’re using CSV uploads, make sure to add the parameters to your CSV definition.
Adjust supports many placeholders which you can use to pass information from the SDK to your URL. For example, the {idfa}
placeholder for iOS and the {gps_adid}
placeholder for Android. The {publisher_parameter}
placeholder presents all callback parameters in a single string.
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button. The following callback parameters are added:
The event_token
The revenue_amount
generated by the event
The resulting callback URL looks like this:
http://www.mydomain.com/callback?event_token=g3mfiw&revenue_amount=0.05
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventCallbacks: UIButton ?
@IBAction func btnRecordEventCallbacks ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
event ? . addCallbackParameter ( "event_token" , value : "g3mfiw" )
event ? . addCallbackParameter ( "revenue_amount" , value : "0.05" )
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordCallbackEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordCallbackEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[event addCallbackParameter: @"event_token" value: @"g3mfiw" ];
[event addCallbackParameter: @"revenue_amount" value: @"0.05" ];
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordCallbackEvent = document. getElementById ( 'btnRecordCallbackEvent' )
btnRecordCallbackEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' );
adjustEvent. addCallbackParameter ( 'event_token' , 'g3mfiw' );
adjustEvent. addCallbackParameter ( 'revenue_amount' , '0.05' );
Adjust. trackEvent (adjustEvent);
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordCallbackEvent" >
Record event with callback parameters
callback_params {"event_token":"g3mfiw","revenue_amount":"0.05"}
Add partner parameters
- ( void )addPartnerParameter:(nonnull NSString * )key value:(nonnull NSString * )value;
You can send extra information to your network partners by adding partner parameters .
Adjust sends partner parameters to external partners you have set up. This information is useful for more granular analysis and retargeting purposes. Adjust’s servers forward these parameters once you have set them up and enabled them for a partner.
Add partner parameters to your event by calling the addPartnerParameter
method with NSString
key-value arguments. You can add multiple parameters by calling this method multiple times.
let event = ADJEvent ( eventToken : "abc123" )
event ? . addPartnerParameter ( "key" , value : "value" )
event ? . addPartnerParameter ( "foo" , value : "bar" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[event addPartnerParameter: @"key" value: @"value" ];
[event addPartnerParameter: @"foo" value: @"bar" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent (eventToken);
adjustEvent. addPartnerParameter ( "key" , "value" );
adjustEvent. addPartnerParameter ( "foo" , "bar" );
Adjust. trackEvent (adjustEvent);
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button. The following partner parameters are added:
The product_id
of the associated product
The user_id
of the user who triggered the event
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventPartnerParams: UIButton ?
@IBAction func btnRecordEventPartnerParams ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
event ? . addPartnerParameter ( "product_id" , value : "29" )
event ? . addPartnerParameter ( "user_id" , value : "835" )
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordPartnerParamsEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordPartnerParamsEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[event addPartnerParameter: @"product_id" value: @"29" ];
[event addPartnerParameter: @"user_id" value: @"835" ];
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordPartnerParamsEvent = document. getElementById ( 'btnRecordPartnerParamsEvent' )
btnRecordPartnerParamsEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' );
adjustEvent. addPartnerParameter ( 'product_id' , '29' );
adjustEvent. addPartnerParameter ( 'user_id' , '835' );
Adjust. trackEvent (adjustEvent);
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordPartnerParamsEvent" >
Record event with partner parameters
partner_params {"product_id":"29","user_id":"835"}
Add a callback identifier
- ( void )setCallbackId:(nonnull NSString * )callbackId;
You can add a custom string identifier to each event you want to measure. Adjust’s servers can report on this identifier in event callbacks. This enables you to keep track of which events have been successfully measured.
Set up this identifier by calling the setCallbackId
method with your ID as an NSString
argument.
let event = ADJEvent ( eventToken : "abc123" )
event ? . setCallbackId ( "Your-Custom-ID" )
ADJEvent * event = [ADJEvent eventWithEventToken: @"abc123" ];
[event setCallbackId: @"Your-Custom-ID" ];
[Adjust trackEvent: event];
var adjustEvent = new AdjustEvent ( "abc123" );
adjustEvent. setCallbackId ( "Your-Custom-ID" );
Adjust. trackEvent (adjustEvent);
Example
This example shows how to record an event with the token g3mfiw
whenever a user interacts with a button. In this example, the callbackId
is set to f2e728d8-271b-49ab-80ea-27830a215147
.
class ViewControllerSwift : UIViewController {
@IBOutlet weak var btnRecordEventCallbackId: UIButton ?
@IBAction func btnRecordEventCallbackId ( _sender : UIButton) {
let event = ADJEvent ( eventToken : "g3mfiw" );
event ? . setCallbackId ( "f2e728d8-271b-49ab-80ea-27830a215147" )
Adjust. trackEvent (event);
#import "ViewControllerObjC.h"
@interface ViewControllerObjC ()
@property ( weak , nonatomic ) IBOutlet UIButton * btnRecordCallbackIdEvent;
@implementation ViewControllerObjC
- ( IBAction ) clickRecordCallbackIdEvent: (UIButton * )sender {
ADJEvent * event = [ADJEvent eventWithEventToken: @"g3mfiw" ];
[event setCallbackId: @"f2e728d8-271b-49ab-80ea-27830a215147" ];
[Adjust trackEvent: event];
setupWebViewJavascriptBridge ( function ( bridge ) {
let adjustConfig = new AdjustConfig ( '2fm9gkqubvpc' , AdjustConfig.EnvironmentSandbox);
adjustConfig. setLogLevel (AdjustConfig.LogLevelVerbose);
Adjust. appDidLaunch (adjustConfig);
var btnRecordCallbackIdEvent = document. getElementById ( 'btnRecordCallbackIdEvent' )
btnRecordCallbackIdEvent. onclick = function ( e ) {
var adjustEvent = new AdjustEvent ( 'g3mfiw' );
adjustEvent. setCallbackId ( 'f2e728d8-271b-49ab-80ea-27830a215147' );
Adjust. trackEvent (adjustEvent);
< div style = "width:300px;height:35px;text-align:center;" >
< button id = "btnRecordCallbackIdEvent" >
Record event with callback ID
callback_id f2e728d8-271b-49ab-80ea-27830a215147