Data elements are the building blocks for rules. Data elements let you create a data dictionary (or data map) of commonly used items on a page, regardless of where they originate (query strings, URLs, or cookie values) for any object that is contained on your site.
It has been observed in some situations where it is required to define a data element dynamically and then use it in the interface for an event-based rule. For example: capturing linkname attribute of a link onclick element or capturing custom page data into data element such as Product Id or Page type.
Creating Event Based Data Element
A user can dynamically capture the value of the event, and can set it when defining the criteria for an event-based rule, within the custom code block using below code:
Var str= $(this).attr("linkname"); // This line will fetch the name of the link clicked when an event click rule is fired on clicking of a link on the page. _satellite.setVar('Link_Name',str); _satellite.getVar('Link_Name'); return true;
Note: The custom code section in the identifier must return true, regardless of whether a
Valid value is available for the data element otherwise, the rule never evaluates as true or runs.
// This data element will now be available like any other within the interface using %Link_Name%
Capturing Custom Page Based Data
Ex- To pass Product Id data into a data element on a product page, write the custom code below in the editor