The DOM Lens adds to or sets the value of a Visitor Profile attribute based on data that are present in the DOM (Document Object Model) on a web page. DOM Lenses allow marketers to specify the Javascript selector(s) to the DOM element that should be collected when encountered on a page view.
Assuming a web page contains the HTML in the example below, the DOM Lens configuration below would set the following Visitor Profile attributes:
<ul id="list">
<li data-desc="color">Red</li>
<li data-desc="color">White</li>
<li data-desc="color">Blue</li>
<ul>
{
type: "dom",
selectors: "#list li",
index: 2,
realtimeParameter:
{
name: "DOM_DATA",
isListParam: true
}
},
{
type: "dom",
selectors: "#list li",
index: 2,
attribute: "data-desc",
realtimeParameter:
{
name: "DOM_DATA_TYPE",
isListParam: true
}
}
Property Name | Type | Description |
---|---|---|
type | string | Must be set to dom for DOM Lenses |
id | string | Optional. The id for the DOM Lens |
name | string | Optional. The name for the DOM Lens |
selectors | string | The Javascript DOM selector method(s) to lookup |
index | number | Optional. The index of the DOM element to target from the selector query starting at 1. Defaults to 1 |
attribute | string | Optional. The DOM element attribute value to use to collect the parameter value. Defaults to the DOM element innerText |
realtimeParameter | LensParameter | The LensParameter settings for the Realtime Parameter |
timeoutMs | number | Optional. A timeout in milliseconds. When specified, the Path Lens will wait the specified number of milliseconds after the RpiWebClient is initialized before evaluating the Path Lens |
Property Name | Type | Description |
---|---|---|
name | string | The name for the Realtime Parameter |
isListParam | boolean | A flag to specify if the Realtime Parameter value is stored as a collection |
trackLastViewed | boolean | Optional. A flag to specify whether an additional Realtime Parameter will be stored with the current value from the Path Lens. Required when isListParam is true |
lastViewedParameterName | string | Optional. The name for the last viewed Realtime Parameter. Required when trackLastViewed is true |
valueMapEnabled | boolean | A flag to specify whether the value collected from the Path Lens should be translated through the valueMap |
valueMap | Map<string, string> | Optional. A Map of value translations for the values collected from the Path Lens. Required when valueMapEnabled is true |
isStrictValueMap | boolean | Optional. A flag to specify whether to use strict value map translations. When true, values not found in valueMap are not sent to RPI Realtime |