ÃÛ¶¹ÊÓƵ

Integrate the ÃÛ¶¹ÊÓƵ Experience Platform Mobile SDK with Commerce

IMPORTANT
The ÃÛ¶¹ÊÓƵ Experience Platform Mobile SDK for iOS supports iOS 11 or later.

Integrating the with the Commerce mobile app allows merchants to send Commerce event data to the Experience Platform edge.

When Commerce event data is available at the edge, it can be accessed by other ÃÛ¶¹ÊÓƵ Experience Cloud applications. For example, you can use the data to build audiences in Real-Time CDP then use those audiences to personalize your Commerce mobile app.

Configuration

To get started using the ÃÛ¶¹ÊÓƵ Experience Platform Mobile SDK with Commerce, install and configure the SDK in the Experience Platform. Then, finalize your configuration in Commerce.

Experience Platform

  1. Learn about mobile app capabilities by reviewing the ÃÛ¶¹ÊÓƵ Experience Cloud in mobile apps tutorial.

  2. the SDK in Experience Platform.

    note note
    NOTE
    The schema you create and configure in the Experience Platform is the same schema you use in the application code in your Commerce mobile app.

Commerce

After you complete the SDK configuration for the Experience platform, add the SDK configuration to Commerce.

  1. To send Commerce event data to the Experience Platform via the SDK, you must provide an XDM schema in the application code. This schema must match the schema for the SDK in the Experience Platform.

    The following example shows how to track the web.webpagedetails.pageViews event and set the identityMap using the email field.

    code language-swift
    let stateName = "luma: content: ios: us: en: home"
    var xdmData: [String: Any] = [
        "eventType": "web.webpagedetails.pageViews",
        "web": [
            "webPageDetails": [
                "pageViews": [
                    "value": 1
                ],
                "name": "Home page"
            ]
        ]
    ]
    
    let experienceEvent = ExperienceEvent(xdm: xdmData)
    Edge.sendEvent(experienceEvent: experienceEvent)
    
    // ÃÛ¶¹ÊÓƵ Experience Platform - Update Identity
    
    let emailLabel = "mobileuser@example.com"
    
    let identityMap: IdentityMap = IdentityMap()
    identityMap.add(item: IdentityItem(id: emailLabel), withNamespace: "Email")
    Identity.updateIdentities(with: identityMap)
    
  2. Connect to the Commerce Cloud environment.

    In your project’s build settings, add the URL to the Commerce GraphQL endpoint. Such as:

    • Debug: http://debug.commercesite.cloud/graphql/
    • Release: http://release.commercesite.cloud/graphql/
  3. To retrieve data from the Commerce GraphQL endpoints, first generate the necessary files and directories in your project using the .

    1. From your project directory, Apollo iOS.

    2. the Apollo Codegen CLI.

      This creates an apollo-codegen-configuration.json file.

    3. Generate the necessary GraphQL files and directories in your project by replacing the contents of the apollo-codegen-configuration.json file with the following:

      code language-json
      {
      "schemaName" : "MagentoAPI",
      "input" : {
          "operationSearchPaths" : [
          "**/*.graphql"
          ],
          "schemaSearchPaths" : [
          "**/*.graphqls"
          ]
      },
      "output" : {
          "testMocks" : {
          "none" : {
          }
          },
          "schemaTypes" : {
          "path" : "../MagentoAPI",
          "moduleType" : {
              "swiftPackageManager" : {
              }
          }
          },
          "operations" : {
          "inSchemaModule" : {
          }
          }
      },
      "schemaDownloadConfiguration": {
          "downloadMethod": {
              "introspection": {
                  "endpointURL": "http://magento24.com/graphql/",
                  "httpMethod": {
                      "POST": {}
                  },
                  "includeDeprecatedInputValues": false,
                  "outputFormat": "SDL"
              }
          },
          "downloadTimeout": 60,
          "headers": [],
          "outputPath": "magento.graphqls"
      }
      }
      
    4. the Commerce GraphQL schema.

      Ensure that the path is to the ./apollo-codegen-config.json file, which contains the reference to the Commerce GraphQL schema.

    5. the source code.

      Ensure that the path is to the ./apollo-codegen-config.json file, which contains the configuration information to generate the necessary files and directories.

    6. Inside the newly created GraphQLGenerated folder, add or edit GraphQL types. For example, you can add a DynamicBlocks.graphql type with the following content:

      code language-graphql
      query dynamicBlocks($input: DynamicBlocksFilterInput){
          dynamicBlocks(input: $input)
          {
              items {
                  content {
                      html
                  }
              }
          }
      }
      

    You have now integrated the ÃÛ¶¹ÊÓƵ Experience Platform Mobile SDK with your Commerce mobile app. Event data flows from your app to the Experience Platform edge.

How to distinguish Commerce events generated from mobile applications

All events contain a field called channel. The channel field contains channel._id and channel._type which for a Luma storefront has namespace values of "https://ns.adobe.com/xdm/channels/web" and "https://ns.adobe.com/xdm/channel-types/web" respectively. For a mobile storefront however, the namespace values are "https://ns.adobe.com/xdm/channels/mobile-app" and "https://ns.adobe.com/xdm/channel-types/mobile" respectively.

Next steps

To learn how to retrieve Real-Time CDP audiences from your mobile Commerce app to inform cart price rules, dynamic blocks, and related product rules, see Audience Activation.

recommendation-more-help
6bf243c8-c8c6-4074-826f-546af445e840