Skip to main content

Velocity Templates

Velocity is a Java-based template engine and can be used in pre-render or post-render to access data about the test and variant ids.

D
Written by Dan Bier
Updated this week

Data Available

Template Name

Description

$r_experimentID

Experiment id

$r_runID

Experience id

$r_runState

Test State (ACTIVE etc)

$r_testID

Project id

$r_type

Test Type (target etc)

$s_mode

Normal or Staging

$testAlias

Test Alias

$_wm_browser

Visitors Browser

Always include /* @wt.parse="vm" */ to gain access to the template

Please be aware most of the above data is only available in the Global scripts (pre-render.js and post-render.js)

Examples of Usage

  1. Passing data to the WTO OBF

/* @wt.parse="vm" */
var WTOTest = new WT.OBF({
r_experimentID:'$r_experimentID',
r_runID: '$r_runID', //note: this is the experience id
r_runState: '$r_runState',
r_testID: '$r_testID', //note this is the project id
r_type: '$r_type',
s_mode: '$s_mode',
testAlias: '$testAlias',
_wm_browser: '$_wm_browser'
});

2. Pushing data to a dataLayer object

/* @wt.parse="vm" */
function trackEvent(eventName) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': eventName,
'project_alias': '$testAlias',
'test_id': '$r_runID',
'experiment_id': '$r_experimentID',
});
}

Did this answer your question?