Edit in GitHubLog an issue

Track events

The SDK provides three event tracking APIs to log events for reporting, segmentation, and various other data collection use cases:

  1. Send events to Edge Network (requires Edge Network extension)
  2. Track user actions (requires Adobe Analytics extension)
  3. Track app states and screens (requires Adobe Analytics extension)

Send events to Edge Network

The Edge Network extension provides an API to send an ExperienceEvent to Edge Network. An Experience Event is an object that contains data conforming to the XDM ExperienceEvent schema definition in Adobe Experience Platform.

In the following reference examples, you'll create an ExperienceEvent and then send it using the sendEvent API.

Additionally, you'll need to add the Environment Details field group and create a custom field group for product reviews that contain the following fields:

  • productSku
  • rating
  • ratingText
  • reviewerId

Create an Experience Event

Java

Copied to your clipboard
Map<String, Object> reviewXdmData = new HashMap<>();
reviewXdmData.put("productSku", "demo123");
reviewXdmData.put("rating", 5);
reviewXdmData.put("reviewText", "I love this demo!");
reviewXdmData.put("reviewerId", "Anonymous user");
Map<String, Object> xdmData = new HashMap<>();
xdmData.put("eventType", "MyFirstXDMExperienceEvent");
xdmData.put(_yourTenantId, reviewXdmData);
ExperienceEvent experienceEvent = new ExperienceEvent.Builder()
.setXdmSchema(xdmData)
.build();

Send the Experience Event to Edge Network

Use the Adobe Experience Platform Edge Mobile Extension to send the Experience Event created in the previous step.

Java

Copied to your clipboard
Edge.sendEvent(experienceEvent, null);

Track user actions (for Adobe Analytics)

This section shows you how to start track user actions in your mobile app. To view and report on this data in those respective solutions, set up Adobe Analytics or another Experience Cloud solution extensions.

Actions are events that occur in your app. Use this API to track and measure an action, where each action has one or more corresponding metrics that increment each time the event occurs. For example, you might call this API for every new subscription, every time an article is viewed, or every time a level is completed.

Java

Syntax

Copied to your clipboard
public static void trackAction(final String action, final Map<String, String> contextData)

Example

Copied to your clipboard
Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackAction("loginClicked", additionalContextData);

Track app states and screens (for Adobe Analytics)

States represent screens or views in your app. The trackState method is called every time a new state is displayed in your application. For example, this method would be called when a user navigates from the home page to the news feed. This method also sends an Adobe Analytics state-tracking hit with optional context data.

On Android, trackState is typically called each time a new activity is loaded.

Java

Syntax

Copied to your clipboard
public static void trackState(final String state, final Map<String, String> contextData)

Example

Copied to your clipboard
Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackState("homePage", additionalContextData);

For more information, see the Mobile Core API Reference.

Get help

Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.