The Javascript Lens adds to or sets the value of a Visitor Profile attribute based on data that is present in Javascript objects or variables accessible on a web page. Javascript Lenses allow marketers to specify the Javascript object or variable value that should be collected when encountered on a page view.
Assuming a web browser user agent is Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36, the Javascript Lens configuration below would set the following Visitor Profile attributes:
{
type: "javascript",
objectName: "navigator.userAgent",
realtimeParameter:
{
name: "USER_AGENT",
isListParam: true
}
}
Property Name | Type | Description |
---|---|---|
type | string | Must be set to javascript for Javascript Lenses |
id | string | Optional. The id for the Javascript Lens |
name | string | Optional. The name for the Javascript Lens |
objectName | string | The name of a Javascript object or variable to lookup |
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 |