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

read
Last updated at:

Overview

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.

Create a Discount Code

First, in Shopify, create a percentage discount code or a monetary discount code according to the type of promotion you want to offer.

The code you create will need to be inserted as a parameter into a link or button in your emails. After you create this code, make sure to have it handy as you move on to update your email template.

If you would like to use a dynamic code, follow the instructions outlined in this article.

Apply a Discount Code and Link to the Checkout Page

To achieve this functionality, you will need to add a parameter to a link or button. When your customer clicks the button they will be taken to the link and the discount will be automatically applied to their next cart.

You can only add one discount code per email. You can use the same code in multiple places, but you cannot use multiple codes.

You can add a discount to the checkout link within your email template.

Add a Discount to the Checkout Link

To add a coupon code inside of a button, you can add a link that points back to your home page, and automatically applies the discount to your customer's cart. We'll give you two options for accomplishing this with static coupon codes, and one option for a dynamic coupon code:

    1. For a static coupon code, format your link like this:

      mysite.com/discount/CouponName

      Here, replace:

      • mysite.com with your website
      • CouponName with the name of the static coupon
    2. You can also format your link like this for a static coupon code:

      mysite.com/?discount=your_code

      Here, replace

      • mysite.com with your website
      • your_code with your coupon code

        Where you see your_code, make sure to replace with the discount code you created in Shopify. Here is an example of a link with a discount code appended to the end:

        mceclip0.png

    3. For a dynamic coupon code, add the following tag to the end of your site link:

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

      Alternatively, you could also use the following link structure:

      mysite.com/discount/{% coupon_code 'your_code' %}

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

You may want to apply a static discount code to a shopping session, but not link the customer directly back to their cart. Instead, you may want to send them to your homepage or a collection page. In this case, the URL structure you would use is:

mysite.com/discount/CouponName?redirect=/new-path

Here, replace:

  • mysite.com with your website
  • CouponName with the name of the static 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

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

In some cases, you may want to apply a dynamic discount code to a shopping session, but not link the customer directly back to their cart. Instead, you may want to send them to your homepage or a collection page. In this case, the URL structure you would use is:

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

Here, replace:

  • mysite.com with your website
  • your_code with your coupon code
  • 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 "?". Change your parameter to the following and it should work:

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

Additional Resources

x
Was this article helpful?
194 out of 354 found this helpful