Documentation
APICreate a Ticket
  • 📔Documentation Guide
  • 📨Data & Engagement Platform
    • Data Model
      • Customer Data
      • Product Catalogue
      • Events
        • Onsite Events
        • Outbound Events
        • Transactions
    • App User Management
      • User Roles
      • App Users
    • Data Management
      • Data Management with API
      • Data Management with Data Feeds
        • Users
          • Import Users
          • Update or Delete a User Trait via File Upload
          • List of Standard User Traits/Attributes
        • Products
        • Events
          • Import Orders
          • Import Events
          • List of Events and Properties
      • Data Export
    • Web Tracking
      • Web Tracking v1 (Legacy)
        • Setup
        • Set up business Units
        • Tracking User Behavior
          • Identify Method
          • Page Method
          • Track Method
          • Opt-Out from Tracking
        • Testing & Debugging
      • Web Tracking v2
        • Setup using Google Tag Manager
        • Setup without a Tag Manager
        • Configuration & Config Commands
        • Tracking User Behavior
          • Identify Method
          • Update Method
          • Page Method
          • Track Method
          • Opt-Out from Tracking
        • Testing & Debugging
      • Migrate Tracking SDK v1 -> v2
      • Mobile Web Tracking
    • User Segmentation
      • Creating a Segment
      • Conditions
      • Combining Segments
    • Messages
      • Frequency Capping
      • Templates
        • Template Builder
      • Integrations
        • Channels
          • SMS
            • Twilio
              • Set up a Twilio Account
              • Set up Twilio Integration
              • Create a Campaign Message
            • Link Mobility
              • Set Up Link Mobility Account
              • Set up Link Mobility Integration
              • Create a Campaign Message
          • SFTP
            • Set up SFTP Integration
            • Create a Campaign Message
          • Direct Mail
            • Optilyz
              • Set up Optilyz Integration
              • Create a Campaign Message
          • Webhooks
            • Single Webhook
              • Set up Webhook Integration
              • Create a Campaign Message
              • Response Data and Custom Events
            • Batch Webhook
              • Set up Batch Webhook Integration
              • Create a Campaign Message
            • Zenloop via CrossEngage Webhook
              • Set up Zenloop Integration (via CrossEngage Webhook)
              • Set up Zenloop Survey
              • Create a Campaign Message
              • Set up Zenloop Survey via ESP
              • Obtain Response Data
            • Google Analytics via Webhook
          • Segment Transfer
            • Facebook
              • Set up Facebook Developer Account
            • Optimizely
              • Set up Optimizely Account
            • Google Analytics
              • Set up Google Analytics Integration
              • Create a Campaign with Google Analytics
              • Using the Google Analytics Integration
            • Airship
              • Set up an Airship Account
              • Set up an Airship Integration
              • Create a Campaign Message with Airship
          • Onsite Display
            • Trbo
              • Set up Trbo Integration
              • Create a Campaign Message in CrossEngage
              • Configure Campaign Message in Trbo
              • Obtain Response Data
          • Email
            • Mailjet
              • Set up Mailjet Integration
              • Obtain Response Data via Webhook
              • Create a Campaign Message
              • Personalize Preview Texts in Mailjet
            • Mandrill (by MailChimp)
              • Set up Mandrill Integration
              • Obtain Response Data via Webhook
              • Create a Campaign Messege
            • Inxmail
              • Set up Inxmail Integration
              • Create a Campaign Message
            • Sendgrid (by Twilio)
              • Set up SendGrid Integration
              • Obtain Response Data via Webhook
              • Create a Campaign Message
            • Mailgun
              • Set up Mailgun Integration
              • Obtain Response Data via Webhooks
              • Create a Campaign Message with Mailgun
            • Episerver (Optimizely)
              • Set up Episerver Integration
              • Create a Campaign Message with Episerver
          • Push Notifications
            • Airship
              • Set up an Airship Account
              • Set up an Airship Integration
              • Create a Campaign Message with Airship
        • Attachments
        • Delete an Integration
      • Personalization
        • Import Data
          • User Profile Data
          • Campaign Data
          • Cart Data
        • Formatting Functions
          • Date Formatting
          • Number Formatting
          • String Formatting
          • Hash Functions
        • General Helper Functions
          • Conditional Functions
          • Filtering Arrays
        • Product Helper Functions
          • Fetch from Product Feed
          • Fetch from Tracking Event
          • Fetch from User Journey
        • Misc. Helper Functions
          • Voucher Helper Function
            • Vouchers: Use Case
          • Event Helper Functions
          • Opt Out Helper Functions
        • Operators
      • Vouchers
        • Creating Vouchers
        • Using Vouchers
    • Campaign Management
      • Campaigns
        • Create an Audience Campaign
        • Create a Real-Time Campaign
        • Control Group
      • Stories
        • Building a Story
        • Use Case: Welcome Story
      • Segment Transfer
        • Create a Segment Transfer Campaign
    • Consent Management
      • Subscription/Consent Management
      • System Opt-Out/Opt-In
      • System Blacklist/Whitelist
    • Prediction Models
      • Create a new Model
      • Feature Engineering
      • SQL Filter
    • System Monitoring
      • Dashboard
        • Segment Tracker
      • Events Overview
      • Activity Log
      • Slack Notifications
        • Setting up Slack Notifications
    • Help & Support
      • System Status
      • Reach out to Customer Support
      • Suggest an Improvement
      • Privacy Policy
    • Glossary - Data & Engagement
  • 📈Predictions Platform
    • Data Model
      • Customer Data
      • Transactions
      • Activities
    • Overview
      • Data Tab
        • Data Tables in the Predictions Platform
      • Insights Tab
      • Model Builder Tab
        • Feature Engineering
        • Custom SQL Filter
        • Model Report
      • Prediction Tab
      • Selections Tab
    • Tutorials
      • Prepare and Validate Data
      • Analyze RFM Customers
      • Create a new Model
      • Predict Campaign Profit
    • Glossary - Predictions
Powered by GitBook
On this page
  • if/else Function
  • Use Cases
  • cif/else Function
  • Use Cases
  1. Data & Engagement Platform
  2. Messages
  3. Personalization
  4. General Helper Functions

Conditional Functions

if/else Function

The #if helper function is used to verify whether a value of a user or event attribute exists or is true. Upon message dispatch, if the verified attribute's value is equal to false, undefined, null, "", 0, or [], CrossEngage will not render the block.

The syntax of this helper function is:

{{#if [attribute]}}
   ...
{{/if}}

Property

Description

attribute

The user or event attribute that is used for the verification. e.g. user.[traits.birthday], [properties.price]

Use Cases

Display content only if it exists

For this example, we only display the user's first name if it exists.

{{#if user.[traits.firstName]}}
    <h1>Hi {{user.[traits.firstName]}}!</h1>
{{else}}
    <h1>Hi there!</h1>
{{/if}}

Once the function is evaluated, it displays either:

<!--Assuming the user's first name would be John.-->
<h1>Hi John!</h1>

or

<!--Whenever the first name attribute does not exist for a user.-->
<h1>Hi there!</h1>

cif/else Function

CrossEngage offers a more advanced version of the #if helper function that allows you to perform additional operations and only display content if a certain criteria is met.

The syntax of this helper function is:

{{#cif '{
    "property": "attribute", 
    "operator": "operator", 
    "value": "value"
}'}}
    ...
{{else}}
    ...
{{/cif}}

Optionally, you may use the {{else}} block that will display other content if the condition is not met. The {{else}} block should be placed within the {{#cif}}{{/cif}} tags for the function to be correctly processed.

Property

Description

attribute

The user or event attribute that is used for the verification. e.g. user.[traits.birthday], [properties.price]

Please note that journey steps helper with array attribute e.g. cart is not supported for advanced If.

operator

The operator that will be used to asses whether the criteria is met or not. e.g. ==. <=. See the list of all available operators and their compatibility below.

value

The value the attribute property will be compared against. e.g male, 0

Use Cases

Gender Based Salutation

For this example, we output the salutation of a client according to their gender.

Dear {{#cif '{
    "property": "user.[traits.gender]", 
    "operator": "==", 
    "value": "male"
}'}}
    Mr. {{user.[traits.lastName]}}
{{else}}
    {{#cif '{
        "property": "user.[traits.gender]", 
        "operator": "==", 
        "value": "female"
    }'}}
        Mrs. {{user.[traits.lastName]}}
    {{else}}
        Visitor
    {{/cif}}
{{/cif}}

Once the function is evaluated, it displays the salutation according to the user's gender. For example, the function may result in:

  • Dear Mr. Doe, if the user is male

  • Dear Mrs. Doe, if the user is female

  • Dear Visitor, if the user's gender is unknown

Stock Level Low

For this example, we output a call to action statement when the stock of a certain product is low.

{{#cif '{
    "property": "[properties.stockQuantity]", 
    "operator": "<", 
    "value": "4"
}'}}
    <p>Less than 4 items available. Buy now!</p>
{{/cif}} 

Once the function is evaluated, if a product's stock is less than 4, it displays the content below in the section where it is used in the message.:

<p>Less than 4 items available. Buy now!</p>

PreviousGeneral Helper FunctionsNextFiltering Arrays

Last updated 1 year ago

For a list of operators that can be used for comparison, please check the page.

📨
Operators