Back to Blog

How to Auto-Apply a Klaviyo Discount Code From a Shopify Email Link

To make a Klaviyo discount link auto apply a code on Shopify, point the email button at your store's discount URL: https://yourstore.com/discount/CODE. For a unique code, put Klaviyo's coupon tag where CODE sits. Checkout links built from an event need a discount parameter instead.

Below are copyable patterns for each destination, the separator rule that trips people up and a short test routine.

Key Takeaway

Pick the pattern by destination. Use /discount/CODE for site pages, add discount= to a checkout URL, and use ? only for the first parameter in a link.

Static or unique: what goes in the CODE slot

Shopify advises against special characters in discount code names so they carry into checkout URLs correctly. Campaigns using unique coupons also need enough codes generated or uploaded before sending. If the code comes out blank or stays a placeholder, see why a Klaviyo coupon code is not showing.

The link patterns at a glance

Replace yourstore.com with your Shopify store domain. These are shown with a static code.

DestinationLink
Home pagehttps://yourstore.com/discount/WELCOME15
Collectionhttps://yourstore.com/discount/WELCOME15?redirect=/collections/new
Producthttps://yourstore.com/discount/WELCOME15?redirect=/products/product-handle
Home page, parameter formhttps://yourstore.com/?discount=WELCOME15
Checkout Started URL{{ event.extra.checkout_url }}&discount=WELCOME15

The unique version of the collection link looks like this:

https://yourstore.com/discount/{% coupon_code 'WELCOME' %}?redirect=/collections/new

Paste the whole line into the button's Link address field. In SMS, paste it straight into the message.

The ? vs & rule

The first parameter in a URL starts with ?. Every additional one starts with &. So look at the link you are adding to, including whatever a variable expands into.

Existing linkAdd
/cart/1234567890:1?discount=CODE
A checkout URL that already contains ?key=...&discount=CODE
/discount/CODE?redirect=/path
/discount/CODE?redirect=/path&utm_source=klaviyo

One more wrinkle: if the redirect destination has several parameters of its own, a bare & inside it will be read as the start of a new parameter on the outer link. As a general URL rule, encode it as %26, then test.

Checkout flow: apply the code to the saved checkout

Shopify sends a checkout URL with the Checkout Started event, so the button can take someone back to their own cart with the code attached.

Preview with a real triggering event and read the rendered URL. If it contains no ?, switch to ?discount=. For the surrounding automation, follow our abandoned cart flow setup guide. If the underlying link opens an empty cart before any discount is added, that is a checkout link problem.

Browse and added to cart flows: redirect to the product

These events happen before a checkout exists, so Klaviyo says the checkout URL variable will not work. Build from the product URL in the event instead.

The cut filter strips your domain so only the path is left. Its value must match the start of event.URL exactly, including https:// and www. if present. Also confirm organization.url points to the Shopify store.

Property names can differ between event sources, so preview with an event from the metric that actually triggers your flow. If you are still shaping that series, start with our browse abandonment guide.

Welcome emails and campaigns: send them where they shop

Without an event to build from, hard-code the destination. A first purchase offer in a welcome email might link to a bestseller collection:

https://yourstore.com/discount/{% coupon_code 'WELCOME' %}?redirect=/collections/bestsellers

Prebuilt carts

For a replenishment or bundle button, Shopify's cart permalink loads chosen variants and a code:

https://yourstore.com/cart/1234567890:1?discount=CODE

The number before the colon is the variant ID and the number after it is quantity. Add storefront=true to land on the cart instead of checkout. Shopify now labels this format legacy, though still supported, and recommends its newer /buy permalinks for many new uses. Cart permalinks do not work with selling plans.

Shopify's own shareable link

For a static code, you can skip hand-building: in Shopify admin go to Discounts, open the discount, click Promote and get a shareable link. It only works while the discount is active. Shopify says codes created by third-party apps do not get this link, so use the Klaviyo tag patterns for Klaviyo-generated codes.

UTM parameters

When UTM tracking is on, Klaviyo adds its parameters to web links in the email, apart from links with click tracking disabled. A discount link redirects, so do not assume the tags survive. Click through from a delivered email and check the landing page URL. If they are lost, adjust how the redirect carries them and retest.

A testing routine

  1. Preview with a recent real event and inspect the fully rendered link.
  2. For unique coupons, confirm codes are available, then send a preview to your inbox. The in-app preview only shows a -PREVIEW placeholder.
  3. Click the button on a phone and a computer.
  4. Add a qualifying product and go to checkout. Confirm the discount line, not just the URL.
  5. Check the code in the link matches any code printed in the email.
  6. Between tests, remove the applied discount or clear site cookies. Shopify saves a shareable link's discount to the cart and browser, which can make a broken link look fine.
  7. Repeat with an item already in the cart and with an automatic discount running, if you use one.

When the code does not apply

Check that the discount is active, the cart meets any minimum or product rule, and its combination settings allow it alongside other discounts. Klaviyo also warns that it cannot guarantee auto-apply when the link lands on a page other than checkout, because a site may strip the coupon from the URL. In that case, ask your theme developer, and print the code in the email as a fallback. We suggest doing that anyway.

If you want these links built and tested across your automations, see our flow automation service.

Frequently Asked Questions

Does a discount link create the discount in Shopify?

No. The link only passes a code along. A static code has to exist in Shopify first, and a unique code has to come from a coupon set up in Klaviyo with valid discounts behind it.

Can a cart permalink apply more than one code?

Shopify's developer docs allow multiple codes in the discount parameter, separated by commas. Whether they stack depends on each discount's combination settings.

Does the shopper still see the discount if they browse first?

Shopify says a discount from a shareable link is saved to the cart and browser until removed. Klaviyo still cautions that some sites drop the coupon, so test your own theme.

Will these links work for subscription orders?

Klaviyo states its coupon codes work only for nonrecurring orders, and Shopify cart permalinks do not work with selling plans. Handle subscription discounts through your subscription tool.

Want Discount Links That Just Work?

EcomCure builds Klaviyo flows for Shopify brands and tests the links, codes and tracking before they go live.

Get Your Free Audit