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:  

1
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;
2

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%

Additional Points: 

  • setVar saves the data element on a page level scope – this is okay since you’ll typically only be manually setting these variables when you are referencing elements with $(this).
  • You can also use %% substitutions for these data elements within the UI. For the example above  the data element can be referenced via %link ID%.
  • When you manually override a data element that exists and has a scope, it retains the scope of the element.

Capturing Custom Page Based Data

 Custom page data while creating a data element  such as Product Id, Page type etc. can be captured by writing custom Javascript into the UI by clicking Open Editor and inserting code into the editor window.

3

Ex- To pass Product Id data into a data element on a product page, write the custom code below in the editor 

4
  • A return statement is necessary in the editor window  to indicate what value should be set as the data element value. If a return statement is not included, the default value or an empty string will be returned as the data element value.

Esta obra está autorizada con arreglo a la licencia de Reconocimiento-NoComercial-CompartirIgual 3.0 Unported de Creative Commons.  Los términos de Creative Commons no cubren las publicaciones en Twitter™ y Facebook.

Avisos legales   |   Política de privacidad en línea