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' %}

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

When previewing the message, note that it won't show a live coupon.  

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?
155 out of 293 found this helpful