How to create dynamic countdown timers based on send time

  • 24 October 2023
  • 3 replies
  • 429 views

Userlevel 7
Badge +44
  • Champion & Partner
  • 489 replies

Hi all, 

 

I wanted to share a struggle we've had when using Sendtric to be able to create those nice looking countdown timers that actually don't have a static end date but rather a dynamic end date depending on when somone receives the email. i.e. you're using a dynamic coupon code that expires in x hours. This works well in/with flows.

 

If you're using CountdownMail as a timer I suggest to checkout this article I created previously

 

For Sendtric however the input for the time you need a Unix timestamp, which in a way Klaviyo does not seem to provide out of the box (yet).

The way we've set this up is to first define the {% today %} variable the way we want it so we recreated this with the following

{% today "%Y-%m-%dT%H:%M:%S" as today %} for more information on date values please check this klaviyo article

We basically declared how we'd like to display the current time (which will be auto filled the moment the email gets generated and send).

But having the current time is not enough yet for Sendtric, we actually need to set the time when the timer should reach zero (in a Unix Timestamp form).

This time gets used in the link for the countdown image. 
An example: https://gen.sendtric.com/countdown/123456?to={UNIX TIMESTAMP}

We've replaced the {UNIX TIMESTAMP} with the following to make sure it's working. We've used: {{ today|days_later:1 |format_date_string|date:'U'}}

As you noticed the days_later is in there. This is the time when the coupon should run out, the next day in this case.

 

For help on how to add a sendtric countdown timer in your mail I suggest you check: https://www.sendtric.com/add-countdown-timers-in-klaviyo/

However the above I've shared is not on there.

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO


3 replies

Userlevel 7
Badge +44

Probably I could have also used 

{% now 'U' as now %} and {{ now|days_later:1 |format_date_string|date:'U'}} with the same effect. Sharing it since it requires less characters.

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO

Userlevel 6
Badge +24

Thanks for sharing this @Omar! Definitely bookmarking for when my clients want to implement a countdown timer like that…

 

Warmly,

Gabrielle 

Userlevel 7
Badge +44

@ebusiness pros this did take some back and forth to get working correctly so I thought I'd share and help others as well.

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO

Reply