Collect and map Analytics data

Learn how to map mobile data to Adobe Analytics.

The event data which you collected and sent to Platform Edge Network in earlier lessons is forwarded to the services configured in your datastream, including Adobe Analytics. You map the data to the correct variables in your report suite.

Architecture

Prerequisites

  • Understanding of ExperienceEvent tracking.
  • Successfully sending XDM data in your sample app.
  • An Adobe Analytics report suite that you can use for this lesson.

Learning objectives

In this lesson, you will:

  • Configure your datastream with the Adobe Analytics service.
  • Understand automatic mapping of Analytics variables.
  • Set up processing rules to map XDM data to Analytics variables.

Add Adobe Analytics datastream service

To send your XDM data from the Edge Network to Adobe Analytics, you configure the Adobe Analytics service to the datastream you set up as part of Create a datastream.

  1. In the Data Collection UI, select Datastreams and your datastream.

  2. Then select Add Add Service.

  3. Add Adobe Analytics from the Service list,

  4. Enter the name of the report suite from Adobe Analytics that you want to use in Report Suite ID.

  5. Enable the service by switching Enabled on.

  6. Select Save.

    Add Adobe Analytics as datastream service

Automatic mapping

Many of the standard XDM fields are automatically mapped to Analytics variables. See the full list here.

Example #1 - s.products

A good example is the products variable which can’t be populated using processing rules. With an XDM implementation, you pass all the necessary data in productListItems and s.products are automatically populated via Analytics mapping.

This object:

"productListItems": [
    [
      "name":  "Yoga Mat",
      "SKU": "5829",
      "priceTotal": "49.99",
      "quantity": 1
    ],
    [
      "name":  "Water Bottle",
      "SKU": "9841",
      "priceTotal": "30.00",
      "quantity": 3
    ]
]

results in:

s.products = ";5829;1;49.99,9841;3;30.00"
NOTE
If productListItems[].SKU and productListItems[].name both contain data, the value in productListItems[].SKU is used. See Analytics variable mapping in Adobe Experience Edge for more information.

Example #2 - scAdd

If you look closely, all events have two fields value (required) and id (optional). The value field is used to increment the event count. The id field is used for serialization.

This object:

"commerce" : {
  "productListAdds" : {
    "value" : 1
  }
}

results in:

s.events = "scAdd"

This object:

"commerce" : {
  "productListAdds" : {
    "value" : 1,
    "id": "321435"
  }
}

results in:

s.events = "scAdd:321435"

Validate with Assurance

Using the Assurance you can confirm that you’re sending an experience event, the XDM data is correct and the Analytics mapping is happening as expected.

  1. Review the setup instructions section to connect your simulator or device to Assurance.

  2. Send a productListAdds event (add a product to your basket).

  3. View the ExperienceEvent hit.

    analytics xdm hit

  4. Review the XDM portion of the JSON.

    code language-json
    "xdm" : {
      "productListItems" : [ {
        "SKU" : "LLWS05.1-XS",
        "name" : "Desiree Fitness Tee",
        "priceTotal" : 24
      } ],
    "timestamp" : "2023-08-04T12:53:37.662Z",
    "eventType" : "commerce.productListAdds",
    "commerce" : {
      "productListAdds" : {
        "value" : 1
      }
    }
    // ...
    
  5. Review the analytics.mapping event.

    analytics xdm hit

Note the following in the Analytics mapping:

  • events are populated with scAdd based on commerce.productListAdds.
  • pl (products variable) are populated with a concatenated value based on productListItems.
  • There is other interesting information in this event including all the context data.

Mapping with Context Data

XDM data forwarded to Analytics gets converted into context data including both standard and custom fields.

The context data key is constructed following this syntax:

a.x.[xdm path]

For example:

// Standard Field
a.x.commerce.saveforlaters.value

// Custom Field
a.x._techmarketingdemos.appinformation.appstatedetails.screenname
NOTE
Custom fields are placed under your Experience Cloud Org identifier.
_techmarketingdemos is replaced with your Organization’s unique value.

To map this XDM context data to your Analytics data in your report suite, you can:

Use a field group

  • Add the Adobe Analytics ExperienceEvent Full Extension field group to your schema.

    Analytics ExperienceEvent FullExtension field group

  • Build XDM payloads in your app, conforming to the Adobe Analytics ExperienceEvent Full Extension field group, similar to what you have done in the Track Event Data lesson, or

  • Build rules in your Tags property that use rule actions to attach or modify data to the Adobe Analytics ExperienceEvent Full Extension field group. See for more details Attach data to SDK events or Modify data in SDK events.

Merchandising eVars

If you are using merchandising eVars in your Analytics setup, for example to capture the color of products, like &&products = ...;evar1=red;event10=50,...;evar1=blue;event10=60, you have to extend your XDM payload that you defined in Track event data to capture that merchandising information.

  • In JSON:

    code language-json
    {
      "productListItems": [
          {
              "SKU": "LLWS05.1-XS",
              "name": "Desiree Fitness Tee",
              "priceTotal": 24,
              "_experience": {
                  "analytics": {
                      "events1to100": {
                          "event10": {
                              "value": 50
                          }
                      },
                      "customDimensions": {
                          "eVars": {
                              "eVar1": "red",
                          }
                      }
                  }
              }
          }
      ],
      "eventType": "commerce.productListAdds",
      "commerce": {
          "productListAdds": {
              "value": 1
          }
      }
    }
    
  • In code:

    code language-swift
    var xdmData: [String: Any] = [
      "productListItems": [
        [
          "name":  productName,
          "SKU": sku,
          "priceTotal": priceString,
          "_experience" : [
            "analytics": [
              "events1to100": [
                "event10": [
                  "value:": value
                ]
              ],
              "customDimensions": [
                "eVars": [
                  "eVar1": color
                ]
              ]
            ]
          ]
        ]
      ],
      "eventType": "commerce.productViews",
      "commerce": [
        "productViews": [
          "value": 1
        ]
      ]
    ]
    

Use processing rules

Here is what a processing rule using this data might look like:

  • You Overwrite value of (1) App Screen Name (eVar2) (2) with the value of a.x._techmarketingdemo.appinformation.appstatedetails.screenname (3) if a.x._techmarketingdemo.appinformation.appstatedetails.screenname (4) is set (5).

  • You Set event (6) Add to Wishlist (Event 3) (7) to a.x.commerce.saveForLaters.value(Context) (8) if a.x.commerce.saveForLaters.value(Context) (9) is set (10).

analytics processing rules

IMPORTANT
Some of the automatically mapped variables may not be available for use in processing rules.
The first time you map to a processing rule, the interface does not show you the context data variables from the XDM object. To fix that select any value, Save, and come back to edit. All XDM variables should now appear.

Additional information about processing rules and context data can be found here.

TIP
Unlike previous mobile app implementations, there is no distinction between a page / screen views and other events. Instead you can increment the Page View metric by setting the Page Name dimension in a processing rule. Since you are collecting the custom screenName field in the tutorial, it is highly recommended to map screen name to Page Name in a processing rule.

Migrate from Analytics mobile extension

If you have developed your mobile application using the Adobe Analytics mobile extension you have most likely used MobileCore.trackAction and MobileCore.trackState API calls.

If you decide to migrate to use the recommended Edge Network, you do have options:

SUCCESS
You have set up your app to map your Experience Edge XDM objects to Adobe Analytics variables enabling the Adobe Analytics service in your datastream and using processing rules where applicable.
Thank you for investing your time in learning about Adobe Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, share them on this Experience League Community discussion post.

Next: Send data to Experience Platform

recommendation-more-help
9fed61f5-c338-47ad-8005-0b89a5f4af8b