Sample XDM Implementation
Prerequisites for this tutorial
Before starting this tutorial, please read and follow the steps in the getting started with Adobe Experience Platform tutorial.
Download the sample application
Java
Download the Android Sample application from the Adobe Experience Platform SDK GitHub.
To get started, follow the steps described in the installation section of the Adobe Experience Platform SDK GitHub.
Swift
Download the iOS Swift Sample application from the Adobe Experience Platform SDK GitHub.
To get started, follow the steps described in the installation section of the Adobe Experience Platform SDK GitHub.
Java
Download the Android Sample application from the Adobe Experience Platform SDK GitHub.
To get started, follow the steps described in the installation section of the Adobe Experience Platform SDK GitHub.
Swift
Download the iOS Swift Sample application from the Adobe Experience Platform SDK GitHub.
To get started, follow the steps described in the installation section of the Adobe Experience Platform SDK GitHub.
Set up the configuration
In the Data Collection UI, go to the Environments tab in the previously created mobile property and click on the Development icon ( ). Find the Environment File ID at the top and copy it.
Set the LAUNCH_ENVIRONMENT_FILE_ID
to the copied Environment File ID in the MainApp
(Android) / AppDelegate
(iOS) class.
Create schema and dataset for product reviews
In the browser, navigate to Adobe Experience Platform and login with your credentials.
Create an XDM Schema as follows:
From the left panel, select Schemas
Select Create schema, followed by XDM ExperienceEvent
Set the name for this schema as "Product Reviews".
Select the Add button (+) to add field groups
- Select Environment Details from the "Use existing field groups" section then select Add field group.
Select the Add button (+) to add field groups
- Select Create new field group and set the name as "Product review", then select Add field group.
In the Schema structure, select the "Product review" field group and select the plus icon (+) next to the schema name "Product Reviews".
Start adding fields as follows. After each, select Apply, then plus icon (+) to add the next field.
Field name Display name Type Required productSkuProduct SKUStringYesreviewTextReview TextStringNoratingRatingIntegerYesreviewerIdReviewer IDStringYesSelect the
reviewerId
and enable it for Identity , enable Primary Identity and select Identity namespace "Email".Select Save.
- The previously created schema wil be used for the profiles you are about to create.
- Select the Schema name, then from the right panel enable the Profile toggle.
- When the Enable for Profile pop-up is displayed, select Enable.
- Create a dataset for the schema:
- Select Datasets from the left panel, followed by Create dataset and Create dataset from schema.
- Search for the previously created "Product Reviews" schema and select it.
- Select Next and name the dataset "Product Reviews", followed by selecting Finish.
- Finally, you will want to include this dataset with Real-time Customer Profile:
- Select the previously created "Product Reviews" dataset.
- From the right panel, enable the Profile toggle.
Send product review
Build XDM objects
You can now implement the product review functionality in the sample application. Navigate to EdgeViewController.swift
(iOS) / EdgeTab.java
(Android) and implement the sendProductReviewXdmEvent
function.
- Create the XDM Experience Event using the
XDM IdentityMap
containing the reviewerEmail
and the review information.
Java
Copied to your clipboard// TODO - Assignment 3Map<String, Object> xdmData = new HashMap<String, Object>();// 1. Add Email to the IdentityMap.// Note: this app does not implement a logging system, so authenticatedState ambiguous is used// in this case. The other authenticatedState values are: authenticated, loggedOutMap<String, Object> identityMap = new HashMap<String, Object>();identityMap.put("Email", new ArrayList<Object>() {{add(new HashMap<String, Object>() {{put("id", reviewerId);put("authenticatedState", "ambiguous");}});}});xdmData.put("identityMap", identityMap);// 2. Add product review details in the custom field group// Note: use your _tenantId here as specified in the Product Reviews Schema in Adobe Experience PlatformxdmData.put("_tenantId", new HashMap<String, Object>() {{put("productSku", product.sku);put("rating", rating);put("reviewText", text);put("reviewerId", reviewerId);}});
Swift
Copied to your clipboard// TODO - Assignment 3var xdmData : [String: Any] = [:]// 1. Add Email to the IdentityMap.// Note: this app does not implement a logging system, so authenticatedState ambiguous is used// in this case. The other authenticatedState values are: authenticated, loggedOutxdmData["identityMap"] = ["Email": [["id": reviewerEmail,"authenticatedState": "ambiguous"]]]// 2. Add product review details in the custom field group// Note: use your _tenantId here as specified in the Product Reviews Schema in Adobe Experience PlatformxdmData["_tenantId"] = ["productSku": products[productIndex].sku,"rating": reviewRating,"reviewText": reviewText,"reviewerId": reviewerEmail]
Java
Copied to your clipboard// TODO - Assignment 3Map<String, Object> xdmData = new HashMap<String, Object>();// 1. Add Email to the IdentityMap.// Note: this app does not implement a logging system, so authenticatedState ambiguous is used// in this case. The other authenticatedState values are: authenticated, loggedOutMap<String, Object> identityMap = new HashMap<String, Object>();identityMap.put("Email", new ArrayList<Object>() {{add(new HashMap<String, Object>() {{put("id", reviewerId);put("authenticatedState", "ambiguous");}});}});xdmData.put("identityMap", identityMap);// 2. Add product review details in the custom field group// Note: use your _tenantId here as specified in the Product Reviews Schema in Adobe Experience PlatformxdmData.put("_tenantId", new HashMap<String, Object>() {{put("productSku", product.sku);put("rating", rating);put("reviewText", text);put("reviewerId", reviewerId);}});
Swift
Copied to your clipboard// TODO - Assignment 3var xdmData : [String: Any] = [:]// 1. Add Email to the IdentityMap.// Note: this app does not implement a logging system, so authenticatedState ambiguous is used// in this case. The other authenticatedState values are: authenticated, loggedOutxdmData["identityMap"] = ["Email": [["id": reviewerEmail,"authenticatedState": "ambiguous"]]]// 2. Add product review details in the custom field group// Note: use your _tenantId here as specified in the Product Reviews Schema in Adobe Experience PlatformxdmData["_tenantId"] = ["productSku": products[productIndex].sku,"rating": reviewRating,"reviewText": reviewText,"reviewerId": reviewerEmail]
Note: When sending XDM data for custom field groups, use your _tenantId as shown in the schema.
Use the knowledge from Assignment 1 and connect to an Assurance Session to verify if the XDM data sent from the sample app is in the correct format.
Override the default dataset
- Send the Experience Event using the Adobe Experience Platform Edge extension and specify the dataset identifier for "Product Reviews".
- Copy the
<DatasetIdentifier>
from the "Product Reviews" dataset in Platform and replace it in the sample app implementation where indicated below.
- Copy the
Java
Copied to your clipboard// 3. Send the XDM data using the Edge extension, by specifying Product Reviews Dataset identifiers as// shown in Adobe Experience Platform// Note: the Dataset identifier specified at Event level overrides the Experience Event Dataset specified in the// Datastream configurationxdmData.put("eventType", "product.review");ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, "<DatasetIdentifier>").build();Edge.sendEvent(event, new EdgeCallback() {@Overridepublic void onResponse(Map<String, Object> data) {Log.d("Send XDM Event", String.format("Received response for event 'product.review': %s", data));}});
Swift
Copied to your clipboard// 3. Send the XDM data using the Edge extension, by specifying Product Reviews Dataset identifiers as// shown in Adobe Experience Platform// Note: the Dataset identifier specified at Event level overrises the Experience Event Dataset specified in the// Datastream configurationxdmData["eventType"] = "product.review"let experienceEvent =ExperienceEvent(xdm: xdmData, datasetIdentifier: "<DatasetIdentifier>")Edge.sendEvent(experienceEvent: experienceEvent)
Java
Copied to your clipboard// 3. Send the XDM data using the Edge extension, by specifying Product Reviews Dataset identifiers as// shown in Adobe Experience Platform// Note: the Dataset identifier specified at Event level overrides the Experience Event Dataset specified in the// Datastream configurationxdmData.put("eventType", "product.review");ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, "<DatasetIdentifier>").build();Edge.sendEvent(event, new EdgeCallback() {@Overridepublic void onResponse(Map<String, Object> data) {Log.d("Send XDM Event", String.format("Received response for event 'product.review': %s", data));}});
Swift
Copied to your clipboard// 3. Send the XDM data using the Edge extension, by specifying Product Reviews Dataset identifiers as// shown in Adobe Experience Platform// Note: the Dataset identifier specified at Event level overrises the Experience Event Dataset specified in the// Datastream configurationxdmData["eventType"] = "product.review"let experienceEvent =ExperienceEvent(xdm: xdmData, datasetIdentifier: "<DatasetIdentifier>")Edge.sendEvent(experienceEvent: experienceEvent)
Run the sample application
Run the sample app on a device or simulator in Xcode / Android Studio. Click on the Edge
tab and start testing the Product Review implementation.
- Select a Product from the list.
- In the "XDM Product Review Example" section:
- Fill in the Reviewer email with a sample email address.
- Add the rating for the selected product.
- Write your comment.
- Click Submit Review.
- Repeat these steps multiple times to "collect" product reviews.
View the product reviews in Adobe Experience Platform
After using the sample demo application to send product reviews as XDM Experience Events, query the data in Adobe Experience Platform.
Note: It may take up to 15-20 minutes before the data shows up in Adobe Experience Platform.
Query the dataset which stores the commerce data by doing the following:
Log in to Adobe Experience Platform using your Adobe credentials.
Select your Adobe Experience Cloud organization to the organization ID used to configure the demo application.
On the navigation panel, under Data Management, select Datasets and select the dataset you created at the beginning of this tutorial. From the right panel, copy the
Table name
value.From the left panel, select Queries.
Click the Overview tab, then click Create query.
In the text box, enter a SQL query against your dataset table. Here is an example:
Copied to your clipboardSELECT * FROM paste_your_table_name_hereWHERE eventType = 'product.review' LIMIT 10Select the "Play" icon to run the query. The results will appear in the Results tab at the bottom.
View the Real-time Customer Profile
The customer profile can be viewed in Adobe Experience Platform.
- Select Profiles from the left panel.
- Select Browse and search for the email you sent from the sample app.
- Select the merge policy
_xdm.context.profile
Private graph Timestamp ordered - Select "Email" as the identity namespace.
- For the identity value, enter the same email as you sent from the app.
- Select the Profile ID found in the table.
- Select the merge policy
- Inspect the customer profile.
- Notice that the client-side ECID and the email(s) you sent in XDM format using the Edge extension are now displayed in the Detail view, under the Linked identities section, as well as in the Attributes view.
- In the Events tab you can view the events sent to the dataset(s) enabled for Profile for the selected customer profile.
To learn more about the Adobe Customer Profile, see the Identity Service overview and the Identity namespace overview.
Extra credit: Create audience based on Identity Authentication State
Create an audience in Adobe Experience Platform for the customer profiles where the Authenticated State = Ambiguous
.
- Select Audiences from the left panel, followed by Create audience and Build rule.
- Select Events, followed by XDM Experience Event and Identity Map and add the Authenticated State element in the Start building segment section.
- Select Include Identity Map within email where
Authenticated State
equalsAmbiguous
. - Set the name for this audience, for example "Users with email and authenticated state ambiguous".
- Select Save.
- Once the audience is computed, you can see how many users qualify for this audience.
For more details about segmentation in Adobe Experience Platform, see the Segment Builder user guide.