Blog

How to add dynamic discount codes in Klaviyo

In this guide, I’ll show you how to create unique, dynamic discount codes in Klaviyo. I’ll also show you how to add them in Flows, Campaigns, and how to add auto-apply links, so the codes are applied whenever a customer clicks a CTA.

The video below runs through it with a screen recording, so I recommend checking that out too. 

A quick note, that Klaviyo supports dynamic coupons for Shopify Plus, Shopify, Magento 1 and Magento 2. Other platforms may be supported, but it will need to be integrated.

Auto-apply discount links apply only to Shopify Plus and Shopify.

Creating coupons for flows

Step 1: Create the coupon code for flows

 
In the Klaviyo dashboard, go to your coupons page from the left panel, or if you’re logged in, go to https://www.klaviyo.com/coupons.
 
  1. Click the “Add Coupon” button on the top right, which will open the coupon menu.
  2. The Coupon name is only an internal name to help you and Klaviyo identify which code it is, so feel free to name it something that is a good representation of your code. For example, if I want the code to be a welcome offer with 10% off, I will name it “HELLO10”. Please note that this name is NOT what the end subscriber will see, and it will only be for you internally.
 
  1. Choose what prefix you want to enter, in this example, I’ll put the Prefix “HELLO”. Just note the dynamic coupon will contain 6-8 random characters after this Prefix.
 
  1. Choose the discount type. You can choose to provide a Fixed amount off, percentage off, or a free shipping offer. Just remember, if you are providing a fixed amount off. For example, $10 off their first purchase, remember to put a minimum purchase number, otherwise you’ll just be giving them $10 for free.
 
  1. You can select whether this discount applies to the entire order, select products or a certain collection. For this example, I will choose “Entire Order”.
 
  1. Now you have to choose how you want your code to be activated. Since we are talking about flows, you should choose “Generated coupon codes will become active when they are sent out”, because then Klaviyo will only generate codes and feed them into Shopify once the email is sent.
 
  1. You want to choose that the code will expire after a certain amount of time, like 2 days or 3 days, to really drive scarcity for customers to use the code and make a purchase.

 Step 2: Add Code to Flow Email

Now we have the code named “HELLO10”, let’s head on to our flows (klaviyo.com/flows) and attach this coupon code to a flow email. Here’s the email that delivers the special discount.
 
When we designed this email, we wanted the discount to really stand out. To add the dynamic discount, we need to include this special merge tag {% coupon_code ‘NAME_OF_YOUR_COUPON’ %} for Klaviyo to pull up your dynamic coupon code, and replace “NAME_OF_YOUR_COUPON” with the name you gave the coupon, in this case – HELLO10

Step 3: Auto-apply the discount on links

Next, we want to add this code to the buttons so when a subscriber clicks on the button, the discount is automatically applied to it as well. To do that, include the code in the link like this:
  • If the URL is https://www.COMPANY.com/, and the discount code is DISCOUNTCODE
  • Make the URL https://www.COMPANY.com/discount/DISCOUNTCODE
You can use this URL yourself. Just change COMPANY.com to your site, and change DISCOUNTCODE to the merge tag for your discount. In this case, the URL would be https://www.lunaxskin.com/discount/{% coupon_code ‘HELLL10’ %}.
 
If you want the button to link to a page other than the home page, you need to add a redirect, you can’t just add /discount/DISCOUNTCODE to the end of any URL.
  • If the destination URL is https://www.COMPANY.com/collection/all
  • Make the URL https://www.COMPANY.com/discount/DISCOUNTCODE?redirect=/collection/all
So in our example:
  • The destination URL of https://lunaxskin.com/collections/all with dynamic discount code of {% coupon_code ‘HELLL10’ %} becomes
  • https://www.lunaxskin.com/discount/{% coupon_code ‘HELLO10’ %}?redirect=/collection/all
 
If you’re using this for the abandoned cart flow, it’s a bit different since abandon carts have dynamic links to the cart themselves, so you need to use this slightly altered version. Add this /&discount=DISCOUNTCODE behind your default Abandoned cart merge tag.
 
After that, make sure to click save and change the links throughout your email to the right link, for example the image link and so on.
 
To test whether it works, preview your email, select “Show directly in Klaviyo”, and you’ll see it will say HELLO10-PREVIEW.
This means that Klaviyo is pulling your dynamic coupon correctly. If you accidentally mistyped something, Klaviyo will actually say “Unable to find coupon with code” and it will block the email from sending out, so that’s a good safe-proof function within Klaviyo.
 
 
To test whether or not the discount code actually works, you can’t test it here, because the coupons, were set so that “coupons are only generated when the email is sent out” you need to receive an email as a subscriber. If it’s a list triggered Flow, add youself to the list and confirm that the code works as designed, and that the links auto-apply the discount.
 
There you have it, how to set up auto apply discount links for flows. Now moving on to Campaigns, which are similar but with a few different steps.
 

Creating Unique Coupons for Campaigns

A lot of the time, you don’t need a unique coupon for a campaign, since the discounts may already be applied to the product, or you don’t mind usuing a generic coupon. There are times though, when unique coupons for campaigns are especially handy, such as when you’re sending to a niche segment when you want customers to have 1-time use discount codes unique to them.
 

Step 1: Set up the coupon

Let’s say we are creating a discount code for a specific campaign, for example, a Black Friday campaign. Back in the coupons setup page I’m going to set up a Black Friday $10 off coupon with a minimum purchase of $50, expiring in 5 days time.
The difference this time, it that under activation, we want to set it to be live on a certain date, and expire on a certain date. If Black Friday starts today, and the code lasts the next 5 days, to expire on the 15th of August.
 
Now, because we’ve set it so that coupons will be live from today and NOT when an email is sent out, we need to tell Klaviyo how many dynamic coupon codes to create. This varies between businesses, but you should generate slightly more codes than you need. So if you’re sending out to 1000 subscribers, you should create at least 1000+ coupons, if you’re sending out to 30,000, create 30,000 coupons and so on. If you don’t, the send might be cancelled, or not all subscribers will receive their email.
 
 

It takes a few minutes to generate the coupons, depending on the number of coupons.
 

Step 2: Add dynamic code to your Campaign Email

Use the same discount codes, dynamic tag and links as before.
 
So I’m going to change the coupon codes to my BLACKFRIDAY dynamic tag. Remember the name of your coupon is what you set up earlier in the coupons page. The code becomes {% coupon_code ‘BLACKFRIDAY’ %}
 
Testing is easier for campaigns, unlike the flows, the coupons are already generated. I’ll send one to my inbox and the test will send me a live working coupon in my inbox.
 
And there you have it, now go and have fun with the links and tailor them with your own discounts for your website. Here are some ideas to try:
  • Add a limited time discount to your Welcome series
  • Add a discount for new customers only in your Abandon Cart Recovery series
  • Create a segment of subscribers who haven’t bought yet and offer them free shipping with a unique discount
  • Create a segment of customers who haven’t bought in 6 months and offer them a discount on a specific collection.
 
Remember this blog is also a video above, and posted to our Youtube Channel. To see more like it, check out our channel here.
 
We publish new videos every fortnight to help ecommerce owners like you grow your brand using email and automated marketing.
 
Jared Chuah is an email implementation specialist at Email Experts. He has developed and implemented email strategies for iconic Australian brands, including Bulk Nutrients, Riot Art & Craft, Erstwilder and many more.