How to Increment a Custom Field In Drip

Let’s say you want to keep count of how many times a user performs a certain action in Drip, how can you do that?

Drip doesn’t support this feature natively, but it’s easy to implement. Here’s an example using a rule that counts the number of times a user completed a particular event:

Check out the value tag:

{{ products_created | default: 0 | plus:1 }}

We’re using the Liquid tags with filters in this example. Let’s break it down.

First, you set a variable:

{{ products_created }}

Of course, saying products_created = products_created isn’t very useful, so we want to use a filter to change the data that is output. In this case, we want to say:

products_created = products_created + 1

Which in liquid looks like this:

{{ products_created | plus: 1 }}

This would be fine if we always knew that products_created would be set. We can make this tag more robust by adding an additional filter to set a default to ‘0’ for those cases.

{{ products_created | default: 0 | plus: 1 }}

Using this snippet, you can increment fields in drip.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: