Skip to main content

How to dynamically increase the value of an attribute with Liquid


Customer.io

Introduction

This article will guide you on how to increment an attribute value dynamically in a workflow. You can update attribute values in a workflow using the ‘Create or Update Person’ action.

Problem

The challenge was configuring a 'Create or Update Person' action in the workflow where the attribute should increase dynamically. For example in this use case, each time a person made a referral, the value of 'No. Referrals' attribute should increase by one. Instead, it was showing a static value '1', not growing per each referral as it ought to.

Solution

By employing the use of a liquid code, this problem was resolved. This liquid code checks if a customer already has a value in the 'No. Referrals' attribute and, if so, increments the existing value by one. If the customer doesn't have any previous value in the attribute, it assigns a value of one to start the counting process. This modification enables the 'No. Referrals' value to increase dynamically.

Below is the screenshot of the solution code:


Solution code screenshot

This Liquid uses an if condition:

{% if customer["No. Referrals"] %}{{customer["No. Referrals"] | plus:1}}{% else %}1{% endif %}

 

Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings