Learn how to send events to the Adobe Experience Platform Edge Network with your XDM object using tag rules. A tag rule is a combination of events, conditions, and actions that tells the tag property to do something. With Platform Web SDK, rules are used to send events to Platform Edge Network with the right data.
At the end of this lesson, you are able to:
You are familiar with Data Collection tags and the Luma demo site and have completed the previous lessons in the tutorial:
To manage rules in tags, it is recommended to follow a standard naming convention. This tutorial uses a five-part naming convention:
where;
In tags, rules are used to execute actions (fire calls) under various conditions. The Platform Web SDK tags extension includes two actions that are used in this lesson:
In the rest of this lesson we:
Create a rule with the Update variable action to define a “global configuration” of XDM fields.
Create additional rules with the Update variable action that override our “global configuration” and contribute additional XDM fields under certain conditions (for example, adding product details on product pages).
Create another rule with the Send Event action, which will send the complete XDM object to Adobe Experience Platform Edge Network.
All of these rules will be sequenced properly using the “order” option.
This video gives an overview of the process:
To create a tag rule for the global XDM fields:
Open the tag property that you are using for this tutorial
Go to Rules in the left navigation
Select the Create New Rule button
Name the rule all pages - library loaded - set global variables - 1
In the Events section, select Add
Use the Core Extension and select Library Loaded (Page Top) as the Event Type
Select Advanced dropdown and enter 1
as the Order
The lower the order number, the earlier it executes. Therefore, we give our “global configuration” a low order number.
Select Keep Changes to return to the main rule screen
In the Actions section, select Add
As the Extension, select Adobe Experience Platform Web SDK
As the Action Type, select Update variable
As the Data element, select the xdm.variable.content
you created in the Create data elements lesson
Now, map your data elements to the schema used by your XDM object. You can map to individual properties or entire objects. In this example, you map to individual properties:
Find the eventType field and select it
Enter the value web.webpagedetails.pageViews
To understand what values to populate in the eventType
field, you must go to the schema page and select the eventType
field to view the suggested values on the right rail. You can also enter a new value, if needed.
Next, find the identityMap
object in the schema and select it
Map to the identityMap.loginID
data element
XDM fields will not be included in the network request if the data element is null. Therefore, when the user is not authenticated and the identityMap.loginID
data element is null, the identityMap
object will not be sent. This is why we can define it in our “global configuration”.
Scroll down until you reach the web
object
Select to open it
Map the following data elements to the corresponding web
XDM variables
web.webPageDetials.name
to %page.pageInfo.pageName%
web.webPageDetials.server
to %page.pageInfo.server%
web.webPageDetials.siteSection
to %page.pageInfo.hierarchie1%
Set web.webPageDetials.pageViews.value
to 1
While neither eventType
set to web.webpagedetails.pageViews
nor web.webPageDetails.pageViews.value
are required for Adobe Analytics to process a beacon as a page view, it is useful to have a standard way to indicate a page view for other downstream applications.
Select Keep Changes and then Save the rule in the next screen to finish creating the rule
Now, start to use Update variable in additional, sequenced rules to enrich the XDM object before sending it to Platform Edge Network.
Rule order determines which rule runs first when an event is triggered. If two rules have the same event type, the one with the lowest number runs first.
Start by tracking product views on the product detail page of Luma:
Select Add Rule
Name it ecommerce - library loaded - set product details variables - 20
Select the under Event to add a new trigger
Under Extension, select Core
Under Event Type, select Library Loaded (Page Top)
Select to open Advanced Options, type in 20
. This order value ensures the rule runs after the all pages - library loaded - set global variables - 1
which sets the global configuration.
Select Keep changes
Under Conditions, select to Add
Leave Logic Type as Regular
Leave Extension as Core
Select Condition Type as Path Without Query String
On the right, enable the Regex toggle
Under path equals set /products/
. For the Luma demo site, it ensures the rule only triggers on product pages
Select Keep Changes
Under Actions select Add
Select Adobe Experience Platform Web SDK extension
Select Action Type as Update variable
Select xdm.variable.content
as the Data element
Scroll down to the commerce
object
Open the productViews object and set value to 1
Setting commerce.productViews.value=1 in XDM automatically maps to the prodView
event in Analytics
Scroll down to eventType
and set it to commerce.productViews
Because this rule has a higher order, it will overwrite the eventType
set in the “global configuration” rule. eventType
can only contain one value and we recommend setting it with the most valuable event.
Scroll down to and select productListItems
array
Select Provide individual items
Select Add Item
The productListItems
is an array
data type so it expects data to come in as a collection of elements. Because of the Luma demo site’s data layer structure and because it’s only possible to view one product at a time on the Luma site, you add items individually. When implementing on your own website, depending on your data layer structure, you may be able to provide an entire array.
Select to open Item 1
Map productListItems.item1.SKU
to %product.productInfo.sku%
Select Keep Changes
Select Save to save the rule
You can map entire array to an XDM object, provided the array matches the format of the XDM schema. The custom code data element cart.productInfo
you created earlier loops through the digitalData.cart.cartEntries
data layer object on Luma and translates it into the required format of the productListItems
object of the XDM schema.
To illustrate, see the comparison below of the Luma site data layer (left) to the translated data element (right):
Compare the data element to the productListItems
structure (hint, it should match).
Note how numeric variables are translated, with string values in the data layer such as price
and qty
reformatted to numbers in the data element. These format requirements are important for data integrity in Platform and are determined during the configure schemas step. In the example, quantity uses the Integer data type.
Now, let’s map our array to the XDM object:
Create a new rule named ecommerce - library loaded - set shopping cart variables - 20
Select the under Event to add a new trigger
Under Extension, select Core
Under Event Type, select Library Loaded (Page Top)
Select to open Advanced Options, type in 20
Select Keep Changes
Under Conditions, select to Add
Leave Logic Type as Regular
Leave Extensions as Core
Select Condition Type as Path Without Query String
On the right, do not enable the Regex toggle
Under path equals set /content/luma/us/en/user/cart.html
. For the Luma demo site, it ensures the rule only triggers on the cart page
Select Keep Changes
Under Actions select Add
Select Adobe Experience Platform Web SDK extension
Select Action Type as Update variable
Select xdm.variable.content
as the Data element
Scroll down to the commerce
object and select to open it.
Open the productListViews object and set value to 1
Setting commerce.productListViews.value=1 in XDM automatically maps to the scView
event in Analytics
Select eventType
and set to commerce.productListViews
Scroll down to and select productListItems array
Select Provide entire array
Map to cart.productInfo
data element
Select Keep Changes
Select Save to save the rule
Create two other rules for checkout and purchase following the same pattern with the below differences:
Rule name: ecommerce - library loaded - set checkout variables - 20
Condition: /content/luma/us/en/user/checkout.html
Set eventType
to commerce.checkouts
Set commerce.checkout.value
to 1
This is equivalent to setting scCheckout
event in Analytics
Rule name: ecommerce - library loaded - set purchase variables - 20
Condition: /content/luma/us/en/user/checkout/order/thank-you.html
Set eventType
to commerce.purchases
Set commerce.purchases.value
to 1
This is equivalent to setting purchase
event in Analytics
Set commerce.order.purchaseID
to the cart.orderId
data element
Set commerce.order.currencyCode
to the hardcoded value USD
This is equivalent to setting s.purchaseID
and s.currencyCode
variables in Analytics
Scroll down to and select productListItems array
Select Provide entire array
Map to cart.productInfo.purchase
data element
Select Keep Changes
Select Save
When you are done, you should see the following rules created.
Now that you have set the variables, you can create the rule to send the complete XDM object to Platform Edge Network with the Send event action.
On the right, select Add Rule to create another rule
Name the rule all pages - library loaded - send event - 50
In the Events section, select Add
Use the Core Extension and select Library Loaded (Page Top)
as the Event Type
Select Advanced dropdown and enter 50
in Order. This will ensure this rule fires after all of the other rules you have configured (which had 1
or 20
as their Order).
Select Keep Changes to return to the main rule screen
In the Actions section, select Add
As the Extension, select Adobe Experience Platform Web SDK
As the Action Type, select Send event
As the XDM, select the xdm.variable.content
data element created in the previous lesson
Select Keep Changes to return to the main rule screen
Select Save to save the rule
Next, publish the rule to your development environment so you can verify it works.
To create a library:
Go to Publishing Flow in the left navigation
Select Add Library
For the Name, enter Luma Web SDK Tutorial
For the Environment, select Development
Select Add All Changed Resources
You should see all the tag components created in previous lessons. The Core extension contains the base JavaScript required by all web tag properties.
Select Save & Build for Development
The library may take a few minutes to build and when it is complete it displays a green dot to the left of the library name:
As you can see on the Publishing Flow screen, there is a lot more to the publishing process, which is beyond the scope of this tutorial. This tutorial just uses a single library in your Development environment.
Now, you are ready to validate the data in the request using the Adobe Experience Platform Debugger.
Next Validate with Adobe Experience Platform Debugger
Thank you for investing your time in learning about Adobe Experience Platform Web SDK. If you have questions, want to share general feedback, or have suggestions on future content, please share them on this Experience League Community discussion post