Accessing the ECID

The Experience Cloud Identity (ECID) is a persistent identifier assigned to a user when they visit your website. In certain circumstances, you might prefer to access the ECID (to send it to a third party, for example). Another use case is setting the ECID in a custom XDM field, in addition to having it in the identity map.

You can access the ECID either via Data Prep for Data Collection (recommended) or via tags.

Accessing the ECID via Data Prep (preferred method) accessing-ecid-data-prep

This method uses Data Prep for Data Collection to configure a custom mapping for the ECID.

See the Data Prep for Data Collection documentation to learn how to use this feature.

If you are looking to set the ECID in a custom XDM field, in addition to having it in the identity map, you can do this by setting the source to the following path:

xdm.identityMap.ECID[0].id

Then, set the target to an XDM path where the field is of type string.

Tags

If you need to access the ECID on the client side, use the tags approach as described below.

  1. Ensure your property is configured with rule component sequencing enabled.

  2. Create a new rule. This rule should be used exclusively for capturing the ECID without any other important actions.

  3. Add a Library Loaded event to the rule.

  4. Add a Custom Code action to the rule with the following code (assuming the name you’ve configured for the SDK instance is alloy and there isn’t already a data element of the same name):

    code language-js
     return alloy("getIdentity")
       .then(function(result) {
         _satellite.setVar("ECID", result.identity.ECID);
       });
    
  5. Save the rule.

You should then be able to access the ECID in subsequent rules using %ECID% or _satellite.getVar("ECID"), like you would access any other data element.

recommendation-more-help
12b4e4a9-5028-4d88-8ce6-64a580811743