Elmail Experts logo
ExpertiseBigCommerce Email MarketingEmail AutomationKlaviyo ExpertsShopify Email Marketing
About usCase studiesExpert opinionsContact
< Back

Aug 7, 2020

How to add dynamic discount codes in Klaviyo

By Jared Chuah

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.

Coupon name HELLO10

3. 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.

Prefix (Optional)

4. 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.

Discount type

5. 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”.

6. 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.

7. 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.

Generated coupon codes

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.

Add code to flow email

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:

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.

So in our example:

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.

Preview code

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.

Unable to find code

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.

Coupon setup screenshot

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.

Calendar Dates for couponsAdd codes

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

STEP 2: Add Dynmaic 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:

Check out our YouTube channel, where we have tutorials on how to build up your email marketing. Please subscribe to be notified when future content is released.

Author: 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.