Basic rules allow us to access event data (known as event properties) and use that data to set the value of a custom field, for example.

An event such as Made a purchase stores data about the transaction in it’s properties. These properties can be anything from the product’s SKU number, to it’s price or value. Below is a view of how event properties are displayed on the subscriber timeline.

properties-view-event

Using event properties

Setup a rule under Automation > Rules with the trigger “Performed a custom event” and then enter the name of the event e.g. “Made a Purchase”. On the action side of the rule choose the action that you would like to occur. In the field enter the liquid shortcode for the event property.

Shortcodes for event properties use the following syntax.

{{ event.event_property_identifier }}

The “event” keyword is in reference to the custom event used in the trigger step of the rule. This is the same concept as using the “subscriber” keyword in a shortcode like {{ subscriber.first_name }}.

Let’s setup our rule to tag the subscriber with the item_name property represented in the above screenshot:

eventpropertyexamplerule

Based on the properties above, this rule will apply a tag called “Coaching Session” to the subscriber.

Advanced use of event properties

For the following rule example, we will use our Made a purchase event to set a custom field called “lifetime_value” equal to the value property sent in by the event. We will also learn how to make that field dynamically increment based on multiple purchases.

You might have noticed that under a subscriber’s Properties tab, there is already a Lifetime Value field.

ltv-purchase-api

That field is reserved for use with the Drip Purchases API (Beta). We will not be using that field for these examples.

Create the basic rule

As mentioned above, event properties can be accessed via basic rules.

Create a new basic rule under Automation > Rules and name it something descriptive.

ltvrule

The above rule is now configured to set a custom field called “lifetime_value” equal to the value of the product purchased (represented in cents). We will use cents because Drip records conversions in cents format.

The result:

ltvcustomfield

Great! We now have a rule that will set the value of our “lifetime_value” custom field every time a subscriber fires off that rule. However, the present shortcode will only replace the current value with a new one and will not add the new value to the current.

If the same subscriber makes another purchase from you for $29, we would expect their “lifetime_value” custom field to now hold a value of 7800 (cents).

That doesn’t seem to be the case:

ltvcustom29

Again, this is because our current shortcode will only set, or update the custom field with the value brought in through the most recent Made a purchase event that is recorded for that subscriber.

In the next step, we will modify our markup to allow the custom field to increment it’s value every time the Made a purchase event is recorded for the subscriber.

Incrementing the custom field’s value

We will need to modify the shortcode so that it will take a new value and add it to the value that is currently represented by our “lifetime_value” custom field.

In this step, we are going to replace:

{{ event.value }}

with

{% assign value = event.value %}{{ subscriber.lifetime_value | plus: value }}

Rule example with modified shortcode:

modified-ltv-rule

This revised markup will now take an existing value and add any new values to it. A subscriber that has made two separate purchases from you for $49, and another for $29 will now have a lifetime value custom field set to 7800 (cents):

7800-ltv

We now have a custom field that will keep track of a subscriber’s lifetime value!

Example use case

What can we do with this information? To begin with, we can make decisions within a workflow based on the value of a subscriber’s “lifetime_value” custom field.

Let’s say we want to send “Exclusive VIP” offers in an email if a subscriber has a “lifetime_value” custom field value that is >= 10000 ($100 in cents) by the time they reach a decision in a workflow.

The decision might look something like this:

ltv-workflow-decision

 

Not only have we created a custom field that dynamically increments itself—we were able to use the value of that custom field to automate a decision that will determine whether or not to send the subscriber exclusive rewards and to tag them as a VIP customer!

This is just one example of how this custom field can be used. Keep experimenting!