How to create Magento 2 dynamic coupon code in Klaviyo flow that expires in X days after being sent?

  • 15 August 2021
  • 6 replies

Badge +1

Hi guys


How to create Magento 2 dynamic coupon code in Klaviyo flow that expires in X days after being sent?


Best answer by Dov 17 August 2021, 17:21

View original

6 replies

Userlevel 7
Badge +61

Hi @Evoslim,

Thank you for sharing this question with the Klaviyo Community.

All coupon settings for Magento 2 are handled within the price rule in Magento 2.  Magento 2 Coupons can either be set to never expire, or to expire on a specific date, so you would need to select one of those options when configuring your price rule in Magento 2. At this time, you will not be able to set the coupon to expire relative to when an email is sent in Klaviyo.  For more information on setting up the price rule in Magento and using a Magento coupon in a Klaviyo flow, please see this article from our Help Center: How to Setup Coupons for Magento 2.

Thank you for being a member of our Community.

Userlevel 4
Badge +18

Hi @Evoslim and @Dov -

Since M2 price rules are limited and Klaviyo is platform that knows when the coupon was generated and sent, is there going to be any development on Klaviyo’s end to help with this?

Dov, in this thread you gave an example code snippet for campaign emails. Couldn’t be something developed for Flows, too?


Evoslim, have you found any workaround to this?


The problem is that people are calling and emailing my client a year later wanting to use the coupon; or, not even calling, but still being able to use it. We’d love to create some urgency and only reward those that take action within 30 days. 


Thank you

Userlevel 7
Badge +57

Hey there @DavidSandel,

Jumping in to answer some points regarding your latest comment.

You’re right that M2 has limiting price rules, but because that is handled more on their end there isn’t much we could do with something that isn’t there. However, I have submitted a product feature request with our team so we can get eyes on having this work more with our end.

The thread you are mentioning from Dov is showing an example code snippet for displaying a date within a campaign email. This should also work for flows as well. The code is for displaying a current day and then a current day + X days ahead.

Curious to hear more about:

 Couldn’t be something developed for Flows, too?

would you mind clarifying more into what you are trying to develop? 


Looking forward to hearing back,


Userlevel 4
Badge +18

Hey @alex.hong,

Ah, I see. That code snippet just displays a date. It doesn’t actually make the coupon itself valid or invalid. That’s interesting. We could still display that to create the sense of urgency even though the coupon would, actually, still be valid after the displayed date.

In other news, I talked to our M2 developer and he said he can write to achieve this since each individual coupon code that is generated in M2 is tracked. Basically, when it gets generated and sent out through Klaviyo, M2 records that date. Then we have the possibility of going in there and manually setting an expiration date. But, we have a high volume store so an automatic script would be the solution.

Sadly, it still requires “you” to know and pay an M2 developer to achieve this.

Userlevel 7
Badge +57

Hi @DavidSandel!

Yes you’re right. We’re referring to a different type of code here. That code listed before was just to format a date + X days ahead. You could definitely utilize it for creating a sense of urgency for sure.

Thanks for sharing your findings regarding the M2 developer’s thoughts. It’s interesting how there isn’t an automatic script already preinstalled into M2 that allows for customers to better use the generated expiration codes.

Hopefully, we can work together to find a solution as the Klaviyo product develops!


Have a good day,


I take it this has not progressed due to Klaviyo not seeing this as their responsibility to develop… Interesting as the dotdigital Integration for M2 does include the option to configure expiry in days for a coupon via it’s Magento 2 module/integration.