Unique Coupon Codes for Shopify



For Shopify stores, Klaviyo can automatically create one-time use coupon codes, so each customer receives his/her own unique code. This feature provides an alternative to creating a generic coupon code for a given promotion, which means you don't have to worry about codes being shared.

Example use cases for campaigns include:

  • Discount codes for email subscribers: Reward your subscribers by running an exclusive, email-only promotion using coupon codes.
  • Pre-sale discounts for VIP customers: Send your VIPs unique codes that they can use to purchase from a brand new collection.
  • Shipping delay discount: If some items are back-ordered or you're experiencing delays in order fulfillment, send impacted customers a unique code to thank them for their patience.

Example use cases for flows include:

  • Abandoned Carts: Send a discount code to cart abandoners that haven't bought before -- a code only active for 2-4 days will create a sense of urgency and help convert casual browsers into paying customers
  • Win-backs: Send a discount to buyers who haven't come back recently, incentivizing them to purchase again
  • Welcome series: Give new subscribers a discount code as soon as they join your email list -- you can even increase the savings available through the code if they haven't bought after 2 weeks

Create Your Coupon Code in Klaviyo

First, navigate to the Coupons tab in your Klaviyo account and click Add Coupon in the upper right-hand corner.

If you haven't given Klaviyo the proper permissions to create Shopify coupons for your account, you may need to click a button and update your integration settings. When you click to update your integration settings, we will re-authenticate with Shopify and then you will be brought back into Klaviyo. If you click to update, and then click the back button or navigate elsewhere before this authentication process completes, this will cause your integration to be disabled.


For each coupon, you can set the following properties in Klaviyo: 

  • Name
    This is how the coupon will be identified in Klaviyo.
  • Prefix
    Klaviyo will generate a random code for each person, but you can also specify a prefix that will go before every code (i.e. WELCOME).
  • Discount Type
    Choose whether the coupon is a fixed amount off, a percentage, or free shipping.
    • Free Shipping
      For free shipping coupons, you can limit the coupon so it only applies to certain shipping rates, or only when shoppers are shipping to specific countries.
    • Fixed Amount & Percentage Off
      For coupons where you're offering a fixed amount or percentage off an order, you can specify that the coupon only applies to certain products or collections.
  • Minimum Order Subtotal
    Choose whether the coupon is limited to orders meeting a certain subtotal (i.e. 20% off orders over $50).
  • Activation Date
    This is the date the discount offer becomes active -- you can choose to pick a start date, or alternatively select an option where generated coupon codes will become active as they are sent out.
  • Expiration
    Choose when you would like your coupon to expire. There are different options for coupons used in campaign emails versus flow emails.
    • Campaigns
      You have two choices for expiration:
      1. Generated coupon codes will never expire
      2. If you want your discount to have a defined end date, after which generated codes will expire, you can select a firm expiration date
    • Flows
      You have three choices for expiration:
      1. Generated coupon codes will never expire
      2. Generated coupon codes will expire after a certain number of days/hours
      3. If you want your discount to have a defined end date, after which generated codes will expire, you can select a firm expiration date

Use Your Coupon in a Campaign

Once you create the parameters for your coupon, you will need to specify the number of coupon codes that you want to generate. This must be done before you schedule your campaign. When doing this, key things to keep in mind are:

  • You must generate at least as many codes as expected recipients. This means that if you generate fewer codes than the number of estimated recipients, you will not be able to send or schedule the campaign.
  • If your scheduled campaign is set to "Determine recipients at send time," and the actual number of recipients is greater than the number of codes you generate at send time, the extra recipients will be skipped and will not receive the email.
  • If you generate a large number of codes, be sure to allow time between you campaign's desired send time and when you create the codes. Generating a large number of coupon codes may take up to several hours. Because of this, use the estimated number of recipients of the campaign as a framework and do not significantly overestimate the number of codes you need.

You can generate coupon codes for a particular coupon by clicking the dropdown menu and selecting Add Codes.


Once you do this, you will be prompted to input the number of codes you would like to generate. Again, be sure to generate at least as many codes as you have expected recipients for your campaign, otherwise, you will not be able to send or schedule it. 

The "Estimated time to create" area will give you an idea of how long it will take to generate the number of codes you've specified.


Once you click Submit, Klaviyo will begin generating coupon codes for your campaign. A progress bar will appear beneath the coupon name to display progress. You can also track the number of codes that have been created in the Available/Total column.

After the codes have been generated, you can include the coupon tag in your campaign template.

{% coupon_code 'NAME_OF_YOUR_COUPON' %}

Be sure to replace NAME_OF_YOUR_COUPON with the coupon name (must be an exact match of the name -- capitalization matters). For example:


When you preview your emails -- either in-app or by sending a preview email -- you will not see a unique coupon code populate. Coupon codes are only generated in live emails. 

Once you're ready to send or schedule your campaign, navigate to the final page of the campaign scheduling wizard by clicking Review & Send Campaign. Here, you will see a see a Coupon Codes area. If you have fewer coupon codes available than expected recipients, you will not be able to schedule or send your campaign and will need to add more codes.


When you schedule or send your campaign, each recipient will receive a unique coupon code. You can see which code an individual recipient received by navigating to their profile and scrolling to the Coupons section as outlined in the FAQs.

Use Your Coupon in a Flow Email

For coupons used in flow emails, you do not need to specify a specific number of codes to be generated. Once a coupon is created, you can insert it into a flow email using the following dynamic placeholder variable:

{% coupon_code 'NAME_OF_YOUR_COUPON' %}

where you replace NAME_OF_YOUR_COUPON with the coupon name (must be an exact match of the name - capitalization matters).  For example:

When emails are sent out, this variable will be dynamically replaced with a unique discount code.

When you preview your emails -- either in-app or by sending a preview email -- you will not see a unique coupon code populate. Coupon codes are only generated during live sends. 

Best Practices

If you use unique coupons in campaigns and flow emails, there are a few best practices you should stick to:

  • Don't use the same coupon for flows and campaigns. Because you need to specify a number of codes to be generated for campaigns, but not flows, it's a best practice to use different coupons for flows vs. campaigns.
  • Create a separate coupon for each campaign. This way, it will be easier to specify the number of codes you will need for each campaign and you don't risk running out of codes, which would result in some recipients being skipped.

Shopify Coupon FAQs

Does Klaviyo store generated coupon codes anywhere I can access them?

Yes. You can now view recently sent coupons by viewing the Coupons section of your customer's profiles within Klaviyo.

If I use the same coupon placeholder variable in multiple locations within a single email, will Klaviyo populate the same coupon code in all locations within this email?

Yes. Klaviyo will store every coupon code until it expires (up to 1 year). This means if you use the same placeholder variable multiple times in the same email, the same code will populate in all locations.

This also means if you have a multi-email automated flow series, and you send someone a coupon code in Email #1, you can use the same coupon placeholder in Email #3 and we'll give your customer the same exact code (unless the code has already expired). 

What happens if someone loses their code and reaches out to me? How do I send them the same code as a reminder?

If a customer loses an email that featured a discount code, you can view the coupon placeholder value and the unique coupon code sent by viewing the Coupons section of the customer's profile.

If you send the customer a personal email containing the same coupon placeholder variable, the same dynamic code populates in the message. If the coupon has expired, a new unique code of the same type is generated for the message.

How do I find a Klaviyo-generated coupon code in Shopify?

When a coupon is first created in Klaviyo, the corresponding discount will not immediately appear in Shopify - it will only appear after a unique code for that coupon has been generated (i.e. only after a flow email sends out with a corresponding unique code in it).

Here, there are two unique objects:

  • Discount: This is the offer itself, defined by a set of rules
  • Discount Code: This is the unique code generated based on a defined discount

Klaviyo uses Shopify's Bulk Discounts API to create a single discount, and then multiple unique codes for that discount.

In the Shopify Discounts Admin page, you can search for the discount itself by the name you gave the coupon in Klaviyo. After finding this discount, you will see that it's tagged with "App" and there will be a summary of how many codes exist for that coupon and how many were used. If you click on the discount itself, you will see all of the corresponding codes that have been generated.

Please note that you will not be able to search for specific unique codes. This is due to a limitation on Shopify's end, but by searching for the discount name (as named in Klaviyo) you should be able to quickly find the discount and then click to find the codes.


Was this article helpful?
86 out of 112 found this helpful