Add Link that Automatically Applies a Coupon Code to a 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 even 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 any link within your email template. For example, if you're offering a coupon code inside of a button, you can add a link that points back to your home page, and automatically apply's the discount to your customer's cart. This is the parameter you will be adding to the end of your link:


If you're using a dynamic code, replace "your_code" with the tag for your dynamic 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:

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

In some cases, you may want to apply a 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:{% coupon_code 'your_code' %}?redirect=/new-path

Here, replace:

  • 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


If you test this and see that the updated link is not properly applying your discount code, you likely need to adjust the added parameter so that it starts with "&" instead of "?".{% coupon_code 'your_code' %}&redirect=/new-path

Change your parameter to the following and it should work -- if not, contact our Success Team.

Was this article helpful?
22 out of 42 found this helpful