Skip to main content
The campaign template model defines attribute names and functions that can be used inside a template. The main elements are blocks and product positions in blocks. The campaign template model and the product template model are similar and share the same set of lambda expressions, and work the same way with conditional content and collections. The campaign template works with campaign parameters in a similar way to how the product template model works with product parameters.

Campaign name

The name of the campaign.

Syntax

Campaign description

The optional campaign description.

Syntax

Examples

Print description if not empty

Campaign blocks

The blocks collection is a top-level collection with campaign blocks. Each block has a set of product positions, a type, and a template name.

Blocks

Syntax

Examples

Iterate over all blocks
Select second block by index

Type

Each block has its own type, which can be associated with a code block to enable customization.

Description

TOP_SELLERS — Recommends products according to their strategy score. CUSTOMER_BASED — Recommends products based on the visitor’s interest. PRODUCT_BASED — Recommends products based on specified product sets. FAVORITE_BASED — Recommends products based on products that a visitor has marked as a favorite.
Map block title to the template type
Map several values to one block type

Template name

If the campaign block has an associated template, the name of the template can be obtained.

Syntax

Obtain the template name
Enter the block section if the template name is present

Template description

If the campaign block has an associated template, the description of the template can be obtained.

Syntax

Block position

The block position in the campaign, starting from 1.

Syntax

Product positions

A collection of product positions. This allows for getting product images and product page URLs.

Syntax

Examples

Generate product positions with mobile images
Table layout with a fixed number of columns

Product position

The position of a product in a block, starting from 1.
Syntax

Absolute product position

The absolute position of a product in the campaign, starting from 1. {{-index}} shows the position inside the collection, but {{absolutePosition}} shows the campaign block number.
Syntax
A field with a link to the associated product page. For more information, see the product URL template.
Syntax

Product image

Links to images made by the associated product image template.
Description
The URL to the image for the selected template type, defaults to Desktop
The URL to the desktop image
The URL to the mobile image

Mobile and desktop product images

There are two types of product templates: Desktop and Mobile. Each type can produce a different image for the same product. It can be checked if a campaign block has a template with a specific type or not. Each product position has three properties for image links: productImage, productImageDesktop, and productImageMobile. The productImage field produces a link to the selected template type, which defaults to Desktop. A mobile template will be selected inside a mobile section or inside a withMobile filter section.

Mobile section

Code inside this section will produce mobile template links by default. If the template has no mobile template, the mobile link will lead to the desktop product image.
Wrap into mobile section example

Template filters

Template filters allow for selecting only blocks that do or don’t have a specific template type. If a campaign version other than the most recent one is resent, it’s possible that not all blocks will have a product image template. As product images cannot be produced for blocks without a template, these blocks can be excluded.

Description

Selects blocks with a mobile template
Selects blocks with a desktop template

Examples

Select only blocks without a mobile template
Select blocks with a desktop template

Template checks

As with filters, checks can be made to find out if a template type is present. This allows merchandisers to decide what should be shown depending on whether a certain template type is present or not.

Description

Checks if the block has a mobile template
Checks if the block has a desktop template
Checks if the block has any templates at all
Archived campaigns can contain blocks that have no templates.
Last modified on September 11, 2026