📘 This article explains using templates to define variables when optimizing meta tags or HTML elements with PageWorkers. PageWorkers is part of Botify's Activation Suite, available as an option with all Botify plans.
Overview
Templates help you define the new values of your HTML elements at scale. Templates can use variables already present on your page (e.g., a product name) using CSS Selectors. This lets you quickly update an unlimited number of pages with one optimization. You can also include logic in templates, which provides the flexibility to optimize your pages based on specified conditions (e.g., if one condition is met, then add Value A to the page; if a second condition is met, then add Value B to the page). Access the template option in Step 2 of the Page Editor wizard when creating an optimization.
❗️ If your Content-Security-Policy HTTP header includes the script-src
directive, you must also include the unsafe-eval
directive to use PageWorkers templates.
Creating a Template
To create a template:
Choose to define the element with a template when configuring an optimization.
If you chose to apply the optimization to the entire website or to identify pages by scope in Step 1, the only option for providing new values is with a template; you will not see the two options shown in the screenshot above.In the “Define your template” text box, construct your template with text, and either click the name of the desired variable where you want to insert it in the template or create a new variable:
Optionally, define your template further with conditionals and functions.
Preview your template.
Continue with creating the optimization.
Previewing Templates
PageWorkers includes a quick method to let you validate your template while you are defining it within the optimization. To preview how your template will display your optimization on your page:
Identify the URL of the page where you want to test the template. This should be a URL within the defined scope of the optimization.
Click the Test it button next to the template text box. PageWorkers will return the preview below the template definition.
Read next: