How to add a link that applies a unique coupon code at checkout for Shopify

read
Last updated at:

You will learn

Learn how to add a link that automatically applies a unique coupon code to a customer's cart on the checkout page, so they can easily click and place an order. This will be effective across devices, meaning that if a customer abandons a cart on a desktop but receives and clicks through your email on mobile, their cart will still be up to date.

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

While it is also possible to create a link that applies a coupon code to a customer's cart, this method will take the shopper directly to the checkout page.

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. Head to Content > Coupons and follow the instructions outlined in this guide to creating unique coupon codes for Shopify.

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:

https://www.mysite.com/STOREFRONT_ID/checkouts/{{ 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 the following:

  • "mysite" with your website URL
  • "STOREFRONT_ID" with your unique storefront ID
  • "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.

  1. First, navigate to your Analytics tab and select Checkout Started.
  2. Here, click on the timestamp for one of the events.
    The checkout started page within the analytics tab with the timestamp selected.
  3. This will open the metadata associated with this event. After your site's URL, you will see the storefront ID associated with your account.
    The page showing the metadata for this event with your storefront ID highlighted after your site's URL.
  4. Once you've constructed the token, you can insert it into your abandoned cart email template.

Additional resources

x
Was this article helpful?
120 out of 248 found this helpful