How to add link that applies a coupon code to a Shopify cart

read
Last updated at:

You will learn

Learn how to add a link to an email that applies a coupon code to a Shopify cart so that shoppers coming back to make a purchase already have the coupon added. Having the coupon already applied when they get there makes it easier for them to take advantage of the discount and buy quickly.

  1. First you'll create a code, which can be inserted as a parameter into a link.
  2. Then, you'll add the link to a button in your email.
  3. 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. You can either create a static coupon code or unique codes.
    • 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.
    • If you would like to create a dynamic code, follow the instructions outlined in How to create unique coupon codes for Shopify.
      Discounts page in Shopify for SPRINGSALE store showing Discount Code, Discount Type and Value, and Summary.
  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 on the button and set the Action to Go to URL.
  6. Add the link (with the code as a parameter) in the button's Destination URL field. To find out how to format your link, read the next section.
    • Here is an example of a button with a link:
      An example form with the button action set to Go to URL with your link added to the destination URL.
  7. Customize your button text to alert shoppers about your coupon.
  8. 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 snippet:

{{ 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?
376 out of 641 found this helpful