How to Add Link that Applies a Coupon Code to a Shopify Cart

read
Last updated at:

Overview

Learn how to add a link to an email that applies a coupon code to a Shopify cart. If you're offering a discount to customers who decide to head back to your website and complete a purchase, having this discount already applied when they get there makes it easier for them to take advantage of the discount and buy quickly.

  • First you'll create a code, which can be inserted as a parameter into a link.
  • Then, you'll add the link to a button in your email.
  • When the customer clicks the button they will be taken to the link and the discount will be automatically applied to their next cart.

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 Discount Code

1. If you'd like to create a static code, head to Shopify and create a percentage discount code or a monetary discount code according to the type of promotion you want to offer.

Discounts page in Shopify for SPRINGSALE store showing Discount Code, Discount Type and Value, and Summary

If you would like to create a dynamic code, follow the instructions outlined in How to Create Unique Coupon Codes for Shopify.

2. After you create the code, copy it to make sure to have it handy when you start on your email template. 

3. Consider where you'll want to send the coupon. This could be within a flow or campaign email, found via the Flows or Campaigns tab in Klaviyo respectively.  Open the email in the editor.  

4. Add a button for your link to your email, if you haven't already. 

5. Click into the Styles tab of your button. Add the link (with the code as a parameter) in the button's URL field. To find out how to format your link, read the following section. 

Here is an example of a button with a link:

Klaviyo template editor showing button styles tab with text and discount code URL for the button

6. Click Save

Link Formats for Coupon Codes

Note that Klaviyo cannot ensure that a coupon will be auto-applied at checkout if you initially link customers to a non-checkout page; your Shopify site may end up stripping the coupon from the site URL. If you link to a non-checkout page and experience this issue, you should contact your theme developer.

Apply a Discount Code and Link to Checkout 

Shopify syncs the Checkout Started event to Klaviyo with a Checkout URL property, which links back to each customer's unique cart. If you are sending Abandoned Cart emails (triggered by the Checkout Started event) and would like to link a customer to their abandoned cart with a discount code added, add the following to the end of your site link:

{{ event.extra.checkout_url }}&discount={% coupon_code 'CouponName' %}

Apply a Discount Code and Link to Your Homepage

You can add a link that points back to your homepage and automatically applies the discount to your customer's cart. There are multiple formats you can use:

  1. mysite.com/discount/CouponName
  2. mysite.com/?discount=CouponName
    This link format works when your discount is the only parameter you're adding to your link. 
  3. mysite.com/discount/{% coupon_code 'CouponName' %}

With any of these options, you should replace mysite.com with your website, and where you see CouponName, make sure to replace with the discount code you created in Shopify.

Apply a Discount Code and Link to Another Page on Your Site

You may want to apply a discount code to a shopping session, but not link the customer directly back to your homepage or rebuild the customer's abandoned cart. Instead, you may want to send them to a collection page, or another page on your site.

In this case, you can use one of the following URL structures:

  1. mysite.com/discount/CouponName?redirect=/new-path
  2. mysite.com/discount/{% coupon_code 'CouponName' %}?redirect=/new-path

With either structure, replace:

  • mysite.com with your website
  • CouponName with the name of your coupon
  • new-path with the desired URL extension. For example, if you would like to link someone to a specific collection page, you would use ?redirect=/collections/mycollection

Troubleshooting

Here are some quick troubleshooting tips: 

1. When previewing the message, note that it won't show a live coupon. Instead, you’ll see the name of your coupon, followed by -PREVIEW.

2. If you trigger a live send and your coupon code isn't auto-applying to your cart, ask yourself the following questions:

  • Is the item in the cart is already discounted? If it is, Shopify won't allow an additional discount on top of the existing discount.
  • In the coupon definition, are there specific products or collections that the coupon applies to, and does the product in the cart match the configuration? If the product doesn't match the coupon rules, this could be the issue. 

3. If you test your link in a live send and it does not properly apply your discount code, you likely need to adjust the added parameter so that it starts with "&" instead of "?". This is because "?" only works when your discount is the only parameter you're adding to your link, and if you're adding multiple parameters, you'll need to use "&".  Change your link format to the following and it should work:

mysite.com/discount/{% coupon_code 'your_code' %}&redirect=/new-path

Additional Resources

x
Was this article helpful?
343 out of 582 found this helpful