Using Template Parameters

A practical guide about how to use template parameters when creating templates.

Template parameters allow you to define visual parameters in your code. These parameters can then be modified on a separate page by non-technical users using simple inputs. Using parameters allows you to create advanced templates for Web layers, Experiments, Tag manager, Webhooks, and HTML Blocks.


Template parameters are different than Jinja

Jinja allows you to insert personalization. Read more about Jinja here.

Where to use template parameters

Template parameters can be used in the following places:

Basic Syntax

The most basic template parameter looks like this:

[[ parameter ]]

Here's what the user sees in the application:

As you can see, you can define multiple parameters and create a template that is easy to use even for non-technical people. For example, this is a simple Tag template using 3 simple template parameters:

Specifying Parameter Type

You can specify the type of the parameter like this:

[[ parameter : type ]]

Where type is one of these:

  • string (default) – a simple one-line text
  • text – multi-line text
  • number – accepts only a number
  • color – accepts only color values in HEX form and shows a color picker
  • enum – allows the user to select from a set of predefined values
  • recommendation – allows the user to select a recommendation from the project
  • metric – allows the user to select a metric from the project
  • date – date picker
  • time – time picker
  • datetime – date and time picker which allows selecting a timestamp
  • boolean – accepts a true/false value

Using the Enum Type

If you want to use the enum type, you have to use the following syntax:

[[ parameter : enum(value1, value2, value3) ]]

You can provide any number of values you like. The user will see a select box with those values and will be allowed to choose from them.

Using these types allows us to create better templates. We can improve the previous Tag template like this:


Whitespace is not important and is ignored. You can use it however you like. The only whitespace which matters is in the parameter name and enum values. For example, all these are valid:

[[ defaultParam ]]
[[  defaultColorParam  ]]
[[ stringParam:string ]]
[[ multilineTextParam : text ]]
[[ colorParam:  color]]
[[ enumParam :   enum(   simple, advanced) ]]

Default Values

You can specify a default value for a template parameter using this syntax:

[[ parameter | default value ]]
[[ parameter : type | default value ]]

For example, in the template above, we could set the default request method like this:

[[ method : enum(GET, POST) | GET ]]

Recommendations and Metrics

Using the recommendation and metric type allows your users to select a recommendation or a metric from the current project. They'll see a nice select box and you'll get the ID of the picked item in your code.

Special Characters

You can use special characters in the parameter name as well as in the default value and the enum options. For example, these are valid parameter definitions:

[[ text > 99% ]]
[[ text < 99% ]]
[[ headline : string | GET NOW!!! ]]


[[ bannerText ]]
[[ buttonBgColor ]]

[[ buttonText : string ]]
[[ bannerBody : text ]]
[[ showDelay : number ]]
[[ bannerBgColor : color ]]

[[ bannerPrimaryAction | Add to cart ]]
[[ primaryActionColor : color | #ffd500 ]]

[[ httpMethod : enum(GET, POST, PUT, DELETE) | GET ]]
[[ horizontalAlign : enum(left, right) ]]

[[ recommendation model : recommendation ]]

[[ when to stop : datetime ]]
[[ target holiday : date ]]

Updated 7 months ago

Using Template Parameters

A practical guide about how to use template parameters when creating templates.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.

We rely on cookies

to optimize our communication and to enhance your customer experience. By clicking on the Accept and Close button, you agree to the collection of cookies. You can also adjust your preferences by clicking on Manage Preferences. For more information please see our Privacy policy.

Manage cookies
Accept & close

Cookies preferences

Accept & close