At the end of this lesson, you will be able to:
Add the ID Service extension
Create a data element to collect your customer IDs
Create a rule that uses the "Set Customer IDs" action to send the customer IDs to Adobe
Use the rule ordering feature to sequence rules that fire on the same event
You should have already completed the lessons in the Configure Launch section.
In the top navigation, click Extensions.
Click Catalog to open the Extensions Catalog page.
In the filter at the top, type “id” to filter the catalog, then on the card for the Experience Cloud ID Service, click Install.
Leave all of the default settings and click Save to Library and Build. Note that your Experience Cloud Organization ID has been auto-detected for you.
The ID Service is added to your installed extensions. For more details on the advanced options, see the configuration options documentation.
Note: Each version of the ID Service extension comes with a specific version of
VisitorAPI.js which is noted in the extension description. You update the
VisitorAPI.js version by updating the ID Service extension.
The ID Service extension is one of the few Launch extensions that makes a request without having to use a rule action. The extension automatically makes a request to the ID Service on the first page load of the first visit to a website. Once the ID has been requested, it is stored in a first party cookie beginning with
Open the We.Retail site.
Make sure the Debugger is mapping the Launch property to your Development environment, as described in the earlier lesson.
On the Summary tab of the Debugger, the Launch section should indicate that the Experience Cloud ID Service extension is implemented.
Also, on the Summary tab, the ID Service section should populate with the same Org ID shown on your extension configuration screen in the Launch interface.
The initial request to retrieve the Visitor ID might appear in the ID Service tab of the Debugger. It might have already been requested, though, so don't worry if you don't see it.
After the initial request to fetch the Visitor ID, the ID is stored in a cookie whose name begins with
AMCV_. You can confirm that the cookie has been set by doing the following:
Open your browser's Developer Tools.
Go to the Application tab.
Expand Cookies on the left side.
Click on the domain https://aem.enablementadobe.com.
Look for the
AMCV_ cookie on the right hand side. You might see several because the We.Retail site using both its hardcoded Launch property as well as mapping to your own.
In the Add Data Elements, Rules, and Libraries tutorial, you created a data element and used it in a rule. In this tutorial, you use those same techniques to send a customer ID when the visitor is authenticated.
Start by creating two data elements:
Authentication State: Captures whether the visitor is logged in
Email (Hashed): Captures the hashed version of the email address (used as the customer ID) from the data layer
Create the data element for Authentication State:
Click Data Elements in the top navigation.
Click Add Data Element.
Name the data element "Authentication State."
Data Element Type, select
Click Open Editor, then in the Edit Code window, paste the following:
if (digitalData.user.profile.attributes.loggedIn) return "logged in" else return "logged out"
Save the custom code.
Leave all of the other settings on their default values.
Save the data element.
By knowing the authentication state of the user, you know when a customer ID should exist on the page to send to the ID Service. The next step is to create a data element for the customer ID itself. On the We.Retail demo site, you will use the hashed version of the visitor's email address.
Click Add Data Element.
Name the data element "Email (Hashed)."
Path to variable, paste the following:
Leave all of the other settings on their default values
Save the data element.
The Experience Cloud ID Service passes the customer IDs using a rule action called “Set Customer IDs.” Create a rule to trigger this action when the visitor is authenticated:
In the top navigation, click Rules, then click Add Rule to open the Rule Builder.
Create a new rule called: “All Pages - Top - Authenticated - 10.”
TIP: This naming convention indicates you are implementing this rule at the top of all pages when the user is authenticated and it will have an order of “10.” Using a naming convention like this, rather than naming it for the solutions triggered in the actions, minimizes the overall number of rules needed in this implementation.
Under Events, click Add. 1. For the Event Type select Library Loaded (Page Top). 2. Specify the order “10”. The Order controls the sequence of rules that are triggered by the same event. Rules with a lower order fire before rules with a higher order. In this case, you want to set the customer ID before you fire the Target request, which you will do in the next lesson with a rule with an order of 50 . 3. Click Keep Changes to return to the Rule Builder.
Under Conditions click Add:
For the Condition Type select Value Comparison.
Click the icon to open the Data Element modal.
In the Data Element Modal, click on Authentication State, and then click Select.
Make sure Equals is the operator.
Type "logged in" in the text field, which causes the rule to fire whenever the data element “Authentication State” has has a value of “logged in.”
Click Keep Changes.
Under Actions click Add.
Select the Experience Cloud ID Service extension.
Select the “Set Customer IDs” Action Type.
For the Integration Code enter
For the Value open the Data Element selector modal and select the Email (Hashed) option.
For the Auth State select Authenticated.
Click the Keep Changes button to save the action and return to the Rule Builder.
Click Save to Library and Build.
This rule sends the Customer ID as a variable
crm_id when the visitor is authenticated. Because you specified the order as 10, this rule fires before the All Pages - Library Loaded rule created in the Add Data Elements, Rules, and Libraries tutorial,which uses the default Order value of 50.
To validate your work, log in to the We.Retail site to confirm the behavior of the new rule.
Open the We.Retail site.
Make sure the Debugger is mapping the Launch property to your Development environment, as described earlier.
Click the Login link and log in, using
firstname.lastname@example.org as the username and
test as the password.
Return to the Homepage.
Next, confirm the customer id is sent to the Service using the Debugger extension:
Make sure the tab with the We.Retail site is in focus.
Go to the Experience Cloud ID Service tab.
Click on the cell with the Customer ID -
In the modal, note the customer ID value and that the AUTHENTICATED state is reflected.
Confirm the hashed email value by viewing the source code of the page and looking at the username property. It should match the value you see in the Debugger.
Launch also has rich console logging features. To turn them on, go to the Tools tab in the Debugger and turn on the Launch Console Logging Toggle.
This turns on console logging, both in your browser console and in the Logs tab of the Debugger. You should see the logging of all of the rules you have created so far. New log entries are added to the top of the list, so your rule "All Pages - Library Loaded - Authenticated - 10" should fire before the "All Pages - Library Loaded" rule and appear below it in the Debugger's Console Logging.