You can use the Adjust Extension for Adobe Experience SDK to send event information to Adjust's servers when your users take specific actions. 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, visit the Add events guide in the Help Center.
How it works
Event information is sent to Adjust when the following information is passed to the MobileCore.trackAction
API:
AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT
: a string value that maps to the AdjusttrackEvent
method.contextData
: a HashMap of values used to configure your event.
When you call MobileCore.trackAction
with these arguments, the Adjust extension creates an event instance, passes it to the trackEvent
method, and sends the information to Adjust.
Reference
The contextData
HashMap holds information about an event. Each event is represented by a unique contextData
HashMap. To configure your event instance, add values to HashMap.
The following keys are supported:
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN
Your Adjust event token. You MUST set this value to send event information to Adjust. Check outadd eventsfor more information.
AdjustAdobeExtension.ADOBE_ADJUST_REVENUE
The amount of revenue associated with the event. This value should be a string that represents a numerical value.
AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY
.AnISO 4217currency code.
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX
Append a callback parameter key to this prefix and add your callback parameter value to send callbacks to Adjust.
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX
Append a partner parameter key to this prefix and add your partner parameter value to send callbacks to third parties.
Tutorial: Send an event
To send event information, you need to add a function to your main activity. In this tutorial, you'll build on MainActivity.java
from the integration guide and add a new function called sendEventToAdjust
which will send an event with the following properties:
- An event token:
"g3mfiw"
. - 1 Euro of event revenue.
- A callback parameter with the key
"user_id"
and value"855"
. - A partner parameter with the key
"event_token
and value"g3mfiw"
.
The final result looks like this:
import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.adjust.sdk.Adjust;import com.adjust.sdk.AdjustDeeplink;import com.adobe.marketing.mobile.MobileCore;
import java.util.HashMap;import java.util.Map;
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Intent intent = getIntent(); Uri data = intent.getData(); AdjustDeeplink adjustDeeplink = new AdjustDeeplink(data); Adjust.processDeeplink(adjustDeeplink, getApplicationContext()); }
public void sendEventToAdjust(View view) { String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT; Map<String, String> contextData = new HashMap<String, String>(); contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw"); contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "1.00"); contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR"); contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "user_id", "855"); contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX + "event_token", "g3mfiw");
MobileCore.trackAction(action, contextData); }}
Here's what you need to do:
First, import the following classes:
com.adobe.marketing.mobile.MobileCore
: this class is used to send information to Adobe and Adjust.java.util.HashMap
: this class is used to generate thecontextData
HashMap.java.util.Map
: this class is used to type thecontextData
HashMap.
MainActivity.java import com.adobe.marketing.mobile.MobileCore;import java.util.HashMap;import java.util.Map;Next, create a new function inside the
MainActivity
class calledsendEventToAdjust
. This function takes the applicationView
as an argument and returnsvoid.
MainActivity.java public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Intent intent = getIntent();Uri data = intent.getData();AdjustDeeplink adjustDeeplink = new AdjustDeeplink(data);Adjust.processDeeplink(adjustDeeplink, getApplicationContext());}public void sendEventToAdjust(View view) {}}Inside the
sendEventToAdjust
function, declare a newString
variable calledaction
and assign it the valueAdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT
. This is used to tellMobileCore.trackAction
which action to handle.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;}Create a new HashMap variable called
contextData
. This is used to hold the properties of the event.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();}
Now that the contextData
HashMap is initialized, add values to build the event. You can refer back to the contextData
reference for more information about the uses of each key.
Add your Adjust event token to the HashMap using the
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN
key. This is required to inform Adjust which event you're trying to send.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");}Add the event revenue amount using
AdjustAdobeExtension.ADOBE_ADJUST_REVENUE
for the amount andAdjustAdobeExtension.ADOBE_ADJUST_CURRENCY
for the currency. Both values MUST be passed as strings.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "1.00");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR");}Add a callback parameter using the
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX
key. Append a callback identifier to the key to match the parameter in your callback URL.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "1.00");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "user_id", "855");}Add a partner parameter using the
AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX
key. Append a callback identifier to the key to map it to your partner's placeholder.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "1.00");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "user_id", "855");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX + "event_token", "g3mfiw");}Finally, to send the event information to Adjust, call
MobileCore.trackAction
with youraction
andcontextData
variables.MainActivity.java public void sendEventToAdjust(View view) {String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;Map<String, String> contextData = new HashMap<String, String>();contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "1.00");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "user_id", "855");contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX + "event_token", "g3mfiw");MobileCore.trackAction(action, contextData);}
That's it! When the user performs an action that maps to the sendEventToAdjust
function, an event is constructed and sent to Adjust.