How to Add a Link that Applies a Unique Coupon Code at Checkout for Shopify

Last updated at:


Please note that this feature is only available for abandoned cart emails. Further, when previewing the message, it will not display a live coupon.

Adding a link that automatically applies a unique coupon code to a customer's cart on the checkout page makes it incredibly easy for a customer to click through and place an order. It is also possible to create a link that applies a coupon code to a customer's cart, but this method will take the shopper directly to the checkout page.

Additionally, this will be effective across devices -- this means that if a customer abandons a cart on desktop but receives and clicks through your email on mobile, their cart will be up to date.

Before You Begin

 Knowledge Check

If you have not already, read our guide on How to Integrate with Shopify for step-by-step instructions on integrating, before continuing with this article.

Create a Unique Coupon Code

Before you are able to apply the code to a URL, you'll need to build your coupon code in the Coupons tab. To do this, follow the instructions outlined in this article.

Please note that when you preview the email, you will not see a live coupon in the email. Instead, you will see "NAME_OF_YOUR_COUPON-Preview." You'll need to actually trigger the flow in order to view a live code.

Add the Discount URL to a Template

When constructing the URL, you will need to use the following format:{{ event.extra.token }}?discount={% coupon_code 'NAME_OF_YOUR_COUPON' %}

This token reconstructs the checkout and is unique in each Started Checkout event in Klaviyo. You will need to fill in "mysite" with your website URL, "STOREFRONT_ID" with your unique storefront ID, and "NAME_OF_YOUR_COUPON" with the coupon name (must be an exact match of the name -- capitalization matters).

You can find your storefront ID by clicking on the event data for a Started Checkout event and grabbing the first part of a checkout_url.

First, navigate to your Analytics tab and select Checkout Started. Here, click on the timestamp for one of the events.


This will open the metadata associated with this event. After your site's URL, you will see the storefront ID associated with your account.


Once you've constructed the token, you can insert it into your abandoned cart email template.

Was this article helpful?
118 out of 237 found this helpful