Collect identity data

Learn how to collect identity data in a mobile app.

Adobe Experience Platform Identity Service helps you to gain a better view of your customers and their behaviors by bridging identities across devices and systems, allowing you to deliver impactful, personal digital experiences in real time. Identity fields and namespaces are the glue that joins different data sources together to build the 360-degree real-time customer profile.

Learn more about the Identity extension and the identity service in the documentation.

Prerequisites

  • Successfully built and run app with SDKs installed and configured.

Learning objectives

In this lesson, you will:

  • Set up a custom identity namespace.
  • Update identities.
  • Validate the identity graph.
  • Get ECID and other identities.

Set up a custom identity namespace

Identity namespaces are components of Identity Service that serve as indicators of the context to which an identity relates. For example, they distinguish a value of name@email.com as an email address or 443522 as a numeric CRM ID.

NOTE
The Mobile SDK generates a unique identity in its own namespace, named Experience Cloud ID (ECID) when the app is installed. This ECID is stored in persistent memory on the mobile device and is sent with every hit. The ECID is removed when the user uninstalls the app or when the user sets the Mobile SDK global privacy status to opt-out. In the sample Luma app, you should remove and reinstall the app to create a new profile with its own unique ECID.

To create a new identity namespace:

  1. In the Data Collection interface, select Identities from the left-rail navigation.

  2. Select Create identity namespace.

  3. Provide a Display name of Luma CRM ID and an Identity symbol value of lumaCRMId.

  4. Select Cross-device ID.

  5. Select Create.

    create identity namespace

Update identities

You want to update both the standard identity (email) and the custom identity (Luma CRM ID) when the user logs into the app.

  1. Navigate to Luma > Luma > Utils > MobileSDK in the Xcode Project navigator and find the func updateIdentities(emailAddress: String, crmId: String) function implementation. Add the following code to the function.

    code language-swift
    // Set up identity map, add identities to map and update identities
    let identityMap: IdentityMap = IdentityMap()
    
    let emailIdentity = IdentityItem(id: emailAddress, authenticatedState: AuthenticatedState.authenticated)
    let crmIdentity = IdentityItem(id: crmId, authenticatedState: AuthenticatedState.authenticated)
    identityMap.add(item:emailIdentity, withNamespace: "Email")
    identityMap.add(item: crmIdentity, withNamespace: "lumaCRMId")
    
    Identity.updateIdentities(with: identityMap)
    

    This code:

    1. Creates an empty IdentityMap object.

      code language-swift
      let identityMap: IdentityMap = IdentityMap()
      
    2. Sets up IdentityItem objects for email and CRM ID.

      code language-swift
      let emailIdentity = IdentityItem(id: emailAddress, authenticatedState: AuthenticatedState.authenticated)
      let crmIdentity = IdentityItem(id: crmId, authenticatedState: AuthenticatedState.authenticated)
      
    3. Adds these IdentityItem objects to the IdentityMap object.

      code language-swift
      identityMap.add(item:emailIdentity, withNamespace: "Email")
      identityMap.add(item: crmIdentity, withNamespace: "lumaCRMId")
      
    4. Sends the IdentityItem object as part of the Identity.updateIdentities API call to the Edge Network.

      code language-swift
      Identity.updateIdentities(with: identityMap)
      
  2. Navigate to Luma > Luma > Views > General > LoginSheet in the Xcode Project navigator and find the code to execute when selecting the Login button. Add the following code:

    code language-swift
    // Update identities
    MobileSDK.shared.updateIdentities(emailAddress: currentEmailId, crmId: currentCRMId)
    
NOTE
You can send multiple identities in a single updateIdentities call. You can also modify previously sent identities.

Remove an identity

You can use the Identity.removeIdentity API to remove the identity from the stored client-side identity map. The Identity extension stops sending the identifier to the Edge Network. Using this API does not remove the identifier from the server-side identity graph. See View identity graphs for more information on identity graphs.

  1. Navigate to Luma > Luma > Utils > MobileSDK in the Xcode Project navigator and add the following code to the func removeIdentities(emailAddress: String, crmId: String) function:

    code language-swift
    // Remove identities and reset email and CRM Id to their defaults
    Identity.removeIdentity(item: IdentityItem(id: emailAddress), withNamespace: "Email")
    Identity.removeIdentity(item: IdentityItem(id: crmId), withNamespace: "lumaCRMId")
    currentEmailId = "testUser@gmail.com"
    currentCRMId = "112ca06ed53d3db37e4cea49cc45b71e"
    
  2. Navigate to Luma > Luma > Views > General > LoginSheet in the Xcode Project navigator and find the code to execute when selecting the Logout button. Add the following code:

    code language-swift
    // Remove identities
    MobileSDK.shared.removeIdentities(emailAddress: currentEmailId, crmId: currentCRMId)
    

Validate with Assurance

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

  2. In the Luma app

    1. Select the Home tab and move the Assurance icon to the left.

    2. Select the {width="15/"} icon from the top right.

      {width="300"}

    3. Provide an email address and a CRM Id, or

    4. Select {width="15/"} to randomly generate an Email and CRM ID.

    5. Select Login.

      {width="300"}

  3. Look in the Assurance web interface for the Edge Identity Update Identities event from the com.adobe.griffon.mobile vendor.

  4. Select the event and review the data in the ACPExtensionEventData object. You should see the identities you updated.
    validate identities update

Validate with identity graph

Once you complete the steps in the Experience Platform lesson, you are able to confirm the identity capture in Platforms identity graph viewer:

  1. Select Identities in the Data Collection UI.

  2. Select Identity Graph from the top bar.

  3. Enter Luma CRM ID as the Identity namespace and your CRM Id (for example 24e620e255734d8489820e74f357b5c8) as the Identity value.

  4. You see the Identities listed.

    validate identity graph

INFO
There is no code in the app to reset the ECID, which means you can only reset the ECID (and effectively create a new profile with a new ECID) through an uninstall and a reinstall of the application. To implement the reset of identifiers, see the Identity.resetIdentities and MobileCore.resetIdentities API calls. Be aware though, when using a push notification identifier (see Sending push notifications), that identifier becomes another ‘sticky’ profile identifier on the device.
SUCCESS
You have now set up your app to update identities in the Edge Network and (when set up) with Adobe Experience Platform.
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: Collect profile data

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