Question

How can I implement a weekly streak with the events that I have available in CIO?

  • 26 September 2023
  • 1 reply
  • 45 views

Hi,

We fire an ‘Application Opened’ event to Customer.io whenever a user opens an app.

We would like to know if a user has an ‘Application Opened’ event available every calendar day for the last 5 days. If Yes, we would like to send them a particular email saying ‘Hey, Congratulations. You have been active for last 5 days.’

Do you know if it is possible to fire an email based on the check that a particular event happened every day in the past X days? If yes, how do we do this?

 

Kind Regards,

Uday Singh

Product - beatvest.com

 


1 reply

Hello Uday:

Thank you for your question.^_^

There isn't currently a way, using our segments, to track unique, consecutive daily event occurrences. One workaround though would be to use an Event-Triggered Campaign to keep track of the Events coming in, by incrementing on a Person’s Attribute. Here's how you could possibly do that:

  • Create an Event-Triggered Campaign for the Application Opened Event.
  • Set the Frequency of your Campaign’s Trigger to once a day, which will ensure you never send a person through the campaign more than once a day, thereby preventing from counting the incoming Events more than once a day:

freq.png

  • Add an Update or Add Person Action Block to the workflow and set it to update an event_counter Attribute like this:

Liquid Code Used:
{% assign today = 'now' | date:'%s' %}{% assign yesterday = 'now' | date:'%s' | plus:0 | subtract_day: 1 %}{% if customer.event_counter %}{% if customer.event_counter.last_occurrence > yesterday AND customer.event_counter.last_occurrence < today %}{"count": {{ customer.event_counter.count | plus:1 }},"last_occurrence": {{ today }}}{% else %}{"count": 1,"last_occurrence": {{ today }}}{% endif %}{% endif %}

  • Basically, you need to set your event_counter value as a JSON object that tracks the "count" and the "last_occurence", which would be the last time the event was counted. Since you want five consecutive days in a row, the liquid checks to see if the "last_occurrence" timestamp happened sometime between yesterday and today, i.e. a day hasn't been skipped. If it did happen in that timeframe, then it increments the "count". If not, it resets the count back to 1. I would highly recommend testing this to make sure it works for your needs.
  • Once you know your counter is working, then it's just a matter of setting up a segment that looks for people who have the event_counter attribute equaling to 5, and then you can build a segment-triggered campaign off of that to send your message, saying “Hey, Congratulations. You have been active for last 5 days.”


Hopefully this helps. All the best! 

Michael Boegner

Technical Support Engineer

Customer.io

 

Reply