adjust-icon

Send event information

You can use the Adjust SDK to send event information to Adjust's servers in response to actions taken by your users. Adjust records these events and surfaces them in your Datascape reports, server callbacks, and cloud storage uploads.

For more information on configuring events in Adjust, see the Add events guide in the Help Center.

How it works

Events are represented by AdjustEvent2dx instances. The AdjustEvent2dx class contains properties which you can populate with event information to send to Adjust. The AdjustEvent2dx class MUST be instantiated using an Adjust event token. You can find your event token in AppView by following the steps in the Add events guide. You can set each property to create a complete representation of your event.

Once you've set all the properties you need to set, use the Adjust2dx::trackEvent() method to send the AdjustEvent2dx instance to Adjust. When Adjust receives this object, it records the event information for you to report on.

Reference

The AdjustEvent2dx class is used to hold information about an event. Each event is represented by a unique AdjustEvent2dx instance.

Constructor

Instantiate an AdjustEvent2dx object by passing your event token as an argument.

eventToken (std::string)

Your Adjust event token. SeeAdd eventsfor more information.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
Adjust2dx::trackEvent(adjustEvent);

Set event revenue

Set the revenue amount and currency code of any revenue associated with the event by calling the setRevenue() method.

revenue (double)

The amount of revenue generated by the event.

currency (std::string)

TheISO 4217 codeof the event currency.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
adjustEvent.setRevenue(0.25, "EUR");
Adjust2dx::trackEvent(adjustEvent);

Add callback parameters

Add callback parameters by passing std::string key-value pairs to the addCallbackParameter method. When Adjust receives your AdjustEvent2dx instance, all callback parameters are sent to your callback URL.

key (std::string)

The name (key) of the parameter.

value (std::string)

The value of the parameter.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
adjustEvent.addCallbackParameter("event_token", "g3mfiw");
adjustEvent.addCallbackParameter("revenue_amount", "0.25");
Adjust2dx::trackEvent(adjustEvent);

Add partner parameters

Add callback parameters by passing string key-value pairs to the addPartnerParameter() method. When Adjust receives your AdjustEvent2dx instance, all partner parameters are sent to any external partners you've configured.

key (std::string)

The name (key) of the parameter.

value (std::string)

The value of the parameter.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
adjustEvent.addPartnerParameter("product_id", "29");
adjustEvent.addPartnerParameter("user_id", "835");
Adjust2dx::trackEvent(adjustEvent)

Set deduplication ID

Sets a unique identifier for the AdjustEvent2dx instance to deduplicate revenue events by calling the setDeduplicationId() method. The SDK stores the last ten identifiers and skips revenue events with duplicate transaction IDs.

deduplicationId (std::string)

A unique deduplication ID.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
adjustEvent.setDeduplicationId("5e85484b-1ebc-4141-aab7-25b869e54c49");
Adjust2dx::trackEvent(adjustEvent);

Set a callback ID

Sets a unique identifier for Adjust's servers to report on in event callback by calling the setCallbackId method.

callbackId (std::string)

A unique callback ID.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
adjustEvent.setCallbackId("f2e728d8-271b-49ab-80ea-27830a215147");
Adjust2dx::trackEvent(adjustEvent);

Send an event

Call the Adjust2dx::trackEvent method with your AdjustEvent2dx instance as an argument to send your event to Adjust.

adjustEvent (AdjustEvent2dx)

YourAdjustEvent2dxinstance.

AdjustEvent2dx adjustEvent = AdjustEvent2dx("{YOUR_EVENT_TOKEN}");
Adjust2dx::trackEvent(adjustEvent);

Tutorial

This tutorial demonstrates how to use the AdjustEvent2dx class to send event information to Adjust. You will learn:

  1. How to create create and populate an AdjustEvent2dx instance.
  2. How to use the AdjustEvent2dx class in your app to send event information to Adjust.

To send event information to Adjust, follow these steps:

  1. Instantiate and populate an AdjustEvent2dx object with your Adjust event token. In the example below, the following properties are set:
    • The event revenue is set to 0.25 and the currency code is set to EUR.
    • The event deduplication ID is set to 5e85484b-1ebc-4141-aab7-25b869e54c49.
    • The event token and revenue amount are added as callback parameters.
    • The ID of the associated product and ID of the user who triggered the event are added as partner parameters.
    • The callback ID is set to f2e728d8-271b-49ab-80ea-27830a215147.
  2. At the end of your function, send the information to Adjust by calling Adjust2dx::trackEvent() with your AdjustEvent2dx instance as an argument.
  3. Call your function in response to an action in your app. In the example below, the function is called when the Send Event button is pressed.
#include "Adjust/Adjust2dx.h"
std::string appToken = "{YOUR_APP_TOKEN}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
Adjust2dx::initSdk(adjustConfig);
AdjustEvent2dx adjustEvent = AdjustEvent2dx("g3mfiw");
adjustEvent.setRevenue(0.25, "EUR");
adjustEvent.setDeduplicationId("5e85484b-1ebc-4141-aab7-25b869e54c49");
adjustEvent.addCallbackParameter("event_token", "g3mfiw");
adjustEvent.addCallbackParameter("revenue_amount", "0.25");
adjustEvent.addPartnerParameter("product_id", "29");
adjustEvent.addPartnerParameter("user_id", "835");
adjustEvent.setCallbackId("f2e728d8-271b-49ab-80ea-27830a215147");
Adjust2dx::trackEvent(adjustEvent);

You will see a log output containing the details of your AdjustEvent2dx instance when the event is sent to Adjust.

Path: /event
ClientSdk: cocos2dx5.0.0
Parameters:
android_uuid 781f17d5-5048-4fae-a4e5-77b58bab62b9
api_level 34
app_token {YOUR_APP_TOKEN}
app_version 1.0
attribution_deeplink 1
callback_id f2e728d8-271b-49ab-80ea-27830a215147
callback_params {"event_token": "g3mfiw", "revenue_amount": "0.25"}
connectivity_type 1
country US
cpu_type arm64-v8a
created_at 2024-01-25T14:13:16.151Z+0100
currency EUR
device_manufacturer Google
device_name sdk_gphone64_arm64
device_type phone
display_height 2205
display_width 1080
environment sandbox
event_buffering_enabled 0
event_count 3
event_token {YOUR_EVENT_TOKEN}
gps_adid 5962dfc1-3a53-4692-850b-22c4bf4311a5
gps_adid_attempt 2
gps_adid_src service
hardware_name UE1A.230829.036
language en
mcc 310
mnc 260
needs_response_details 1
os_build UE1A.230829.036
os_name android
os_version 14
package_name com.adjust.examples
partner_params {"product_id": "29", "user_id": "835"}
revenue 0.25
screen_density high
screen_format long
screen_size normal
session_count 2
session_length 23
subsession_count 1
time_spent 23
tracking_enabled 1
deduplication_id 5e85484b-1ebc-4141-aab7-25b869e54c49
ui_mode 1