Dynamic Coupons for Shopify



For all 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 and means you don't have to worry about codes being shared. 

Example uses: 

  • 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


It is unfortunately not currently possible to generate coupon codes in campaign emails using this method. If you want to send coupons in your campaigns, check out our guide to using uploaded coupon codes.

Create your Coupon in Klaviyo

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


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

  • Name
    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
    Whether the coupon is a fixed amount off, a percentage or for free shipping
  • Minimum Order Subtotal
    Whether the coupon is limited to orders meeting a certain subtotal (i.e. 20% off orders over $50)
  • Activation Date
    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
    You have three choices for expiration:
    • Generated coupon codes will never expire
    • Generated coupon codes will expire after a certain number of days/hours
    • If you want your discount to have a defined end date, after which generated codes will expire, you can select a firm expiration date

Each discount type also has a few additional customization options:

  • 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

Use Your Coupon in a Flow Email

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.

Keep in mind, 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. 

Dynamic Coupon FAQs

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

No. Once coupon codes are generated, it isn't possible to view or manage them from within Klaviyo. You can, however, reference generated coupon codes in your Shopify Admin.

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?
78 out of 99 found this helpful