How to send Onsite variables to our JS integration

Our JS SDK allows for variables to be sent for using them in segmentation on onsite campaigns.

Some variables are made available by default:

  • pageType – can be one of product, category, confirmation, checkout, search,
  • random – a random number generated at each page view with a value  between 0 and 100
  • itemId – on pages where an item id is being passed through an event
  • category – on category pages
  • query – on search page, when a query was entered
  • cartValue – available only through custom integration or our ecommerce modules
  • cartCount – available only through custom integration or our ecommerce modules

Those variables or any others can be overwritten if you send your own values with the following Javascript code:

_vteq.push(['setVar', 'variable_name', value]);

Variable_name can be any string.
Value can have any format: string, integer, float. Value is matched with a regex format. If it’s not valid it will not be considered:

You can test it using the following code, in your browser console.

value = 'enter_value here &whatver ! you want';
/^[\s\/a-zA-Z0-9:.\-_;#[email protected]^&*=<>\\,|{}?]+$/.test(value)

Those variables can be used in user segmentation and onsite interaction campaigns.

Related Articles