Add Link that Automatically Applies a Coupon Code to a Cart

read

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 Static Discount to the Checkout Link

To add a static 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:

  1. Add this parameter to the end of your link:

    mysite.com/discount/CouponName

    Here, replace:

    • mysite.com with your website
    • your_code with the name of your 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
  2. Or, you can add this parameter to the end of your link:

    ?discount=your_code

    Here, replace

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

Either one of these two parameters should work when placed at the end of your link.

Add a Dynamic Discount Code to the Checkout Link

Say you're offering 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. This is the parameter you will be adding to the end of your link:

?discount=your_code

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:

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

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

Troubleshooting

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 "?".

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

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

x
Was this article helpful?
29 out of 55 found this helpful