Skip to content
Arnaud PICHERY edited this page Oct 18, 2018 · 1 revision

Custom variables are name-value pair tags that you can associate to your tracking events.

They allow you to define additional details about your events.

Variable scopes

As explained in the Concepts, each event logged in the WT1 system is related to:

  • A visitor : the client that visits the site (ie, the Web browser on the specific device used by the person)
  • A session : a period of time during which a visitor interacts with your site
  • The event itself (be it a page load or a custom event)

These three scopes can all accept custom variables.

For example:

  • At the visitor level, you might want to create a custom variable user_id to associate all events of this visitor to its user identifier in your internal database
  • At the session level, you might want to create a custom variable has_created_cart to indicate whether the visitor has created a cart during this session (you would set it to true when it happens).
    A session-scoped variable is automatically deleted when a new session starts for this user
  • At the event level, you will want to use variables to indicate the type and details of the event. For example:
    • type=videoname=video1 for a custom tracking event designed to log video views
    • type=refreshvalue=item3 if the user refreshed the 3rd item on the page

Using custom variables

Visitor-scoped variables

Visitor-scoped custom variables are set using

_wt1Q.push(["setVisitorParam", "variableName", "variableValue"]);

The same code is used to update the value of a variable.

Visitor custom variables are associated to all further events, until they are deleted.

A single visitor-scoped custom variable can be removed using:

_wt1Q.push(["delVisitorParam", "variableName"]);

All visitor-scoped custom variables can be removed using:

_wt1Q.push(["clearVisitorParams"]);

Setting, deleting or clearing variables only takes effect on any subsequent trackPage or trackEvent call.