Jump to: navigation, search


DevGuide2.png Purpose: Defines the val element, used to submit information in the business event.


The <val> element defines data to submit within the business event. Each occurrence of val in the event specifies a field of the business event. If the <val> element is a child of <trigger>, it can access also to the DOM event matched by the trigger.

Parent Element


Name Mandatory Type Description
name yes string

Name of the value in the generated business event. Must be unique inside the <event> parent. If an <event> element contains multiple values, they must all have different names across this <event> element.

value no JavaScript code Specifies the value to associate with the ‘name’ in the field of the generated event. Can be any JavaScript code which returns a serializable object.


Searched String

The following example adds a value named "searchString" when "SearchEvent" is generated and sent to the Frontend Server. The value is the string entered in the textbox for search.

<event id="SearchEvent" name="Search">
      <trigger name="GoSearchClick" element="td#gobutton input" action="click" url=" " count="1"/>
      <val name="searchString" value="$('input.searchfield:text').val();"/>

The following output is an example of SearchEvent submitted to the Frontend Server if the visitor enters "my search string" in the search box and clicks on the search button. The "EventName" parameter is the "name" attribute of the <event> element, and the <val> element adds a "searchString" parameter to the "data" field. The additional fields are generated automatically by the DSL code:

      "searchString":"my search string"

Use of the Trigger's DOM Event

Let's consider tracking the addToCart event, and including information about the product that was added: name, model, and price. Simple tracking by clicking on the "add to cart" button does not provide information about which button was clicked and which product was added to the cart. To get this information, you need to use the DOM event object: event.target identifies the clicked button which can provide information related to the product:

<event id="AddToCartEvent" name="AddToCart">
    <trigger name="AddToCartTrigger" element="div.info-side img.bdt-addToCart" action="click" url="http://www.MySite.com/*&quot;count="1">
        <val name="productName"value="$(event.target).parents('div.hproduct').find('h3.name').text()"/>
        <val name="productModel" value="$(event.target).parents('div.hproduct').find('span.model').text()"/>        
        <val name="productPrice" value="$(event.target).parents('div.hproduct').find('h4.price').text().replace('Sale:', )"/>

Retrieved from "https://docs.genesys.com/Documentation:GWE:API:val:8.1.1 (2019-08-19 09:03:49)"
This page was last modified on February 27, 2013, at 11:49.


Comment on this article:

blog comments powered by Disqus