Skip to main content

Examples for global helper

Book a demo with the User’s account manager | global helper

Call a function (show a alert modal)

Note that this function should be added to your product’s codebase to provide extended functionality. In this example we will assume you have a performAction function defined like this:
Important: When passing user properties to functions, use the property name without quotes or double braces. Quoted values ('text') are passed as literal strings, while unquoted properties (user_property) are resolved to the user’s actual property value.

Examples using delivery helper

More information about Deliveries can be found on the Deliveries API reference. A Delivery is a REST API for directly triggering an Experience for a specific User.
With a Delivery you can include personalized content for that specific instance of that Delivery. Note that the delivery helper documented here only works for the specific Experience that was triggered via Delivery. Make sure to configure your Experience to only show Manually.
Example Delivery

Book a demo with the User’s account manager | delivery helper

Use custom logic | if block helper

When the condition evaluates to truthy, the content in the if block is used, otherwise the else block is used. A condition is a JS-like combination of a “left hand side”, and “operator” and a “right hand side”. If you’re having issues with this or have a use case that does not seem to be supported, please Contact us.
  • Start an if block, use {{if <CONDITION>}}
  • To end and if block use {{/if}}
  • To add extra cases, use {{elseif <CONDITION>}}
Supported condition operators:
Basic examples
An if block with a else block
The data says spend is 734 and it’s been 13 weeks (so the content in the “if block” will be used).
When the condition does not match, the content in the else case is used.
The data says spend is 734
An elseif can be used to capture a cascading set of conditions
To use an embedded Helper within the if condition, use single curly braces
This example assumes you have a currentUser variable attached to window window.currentUser = { id: '54s1', roles: { name: 'superadmin', items: ['invite_user', 'invite_admin'] } };

Segmentation filter conditions | filter helper

Sometimes you need to do something especially complicated that can’t be captured with == or &&; enter the filter helper. You can use any of the Segmentation filter expressions and many of the simple conditions on user properties can be handled with filter.

Custom helpers

  • Your developers can define the implementation for a custom helper to fit you merge tag needs. A merge tag helper is simply a function that takes arguments (args) and options (opts) and outputs a string.
  • A merge tag follows the typical “mustache syntax” like the other examples above {{helper_name ["arg1", "arg2", ...] [option1="value1" option2="value2"]}}
  • To define a new merge tag pass the name and callback function to chmln.lib.personalize.Mustache.addHelper
  • Please Contact us if you need any help or inspiration
This is a fully working example 🎉
Now, to use the merge tag (based on the example data ↑)