How to set up coupons for Magento 2

Last updated at:

You will learn

Learn how to set up a price rule in Magento 2 and create the coupons in Klaviyo so that your shoppers can easily apply a discount during the checkout process. Magento supports shopping cart price rules.

Klaviyo's Coupons allow Magento 2 stores to do the following:

  • Create new coupons in Klaviyo associated with pre-existing price rules in Magento.
  • Include unique (also called "dynamic") coupons within flow emails, so each recipient receives a unique code.

This guide will walk you through creating a Magento 2 coupon in Klaviyo in 2 steps:

  1. Setup a price rule in Magento 2.
  2. Create the coupon in Klaviyo.

Unique coupon codes are not currently available when sending campaign emails. Sending unique coupon codes in a campaign would require generating thousands of codes per second. Klaviyo cannot guarantee a specific Magento server's rate-limiting settings will not impact the generation of unique coupons at this volume and velocity. Due to this, unique coupons are only available when sending flow emails.

Before you begin

Before you begin, make sure that you've enabled the Magento 2 integration in Klaviyo and installed the Klaviyo extension in Magento.

Setup a price rule in Magento 2

1. From your Magento 2 store navigate to Marketing > Cart Price Rule.

2. Create a price rule by clicking Add New Rule.

The cart price rules menu in magento 2 with add new rule selected.

3. Fill in the rule information:

  • Rule Name: the name of the price rule in Magento 2.
  • Active: choose Yes. If Yes is not selected, the coupon will not work.
  • Websites: if you only have one Magento store, choose the name of your website. If you have multiple Magento stores, choose the store the coupon is associated with.
  • Customer Groups: choose NOT LOGGED IN, or choose a different customer group.
  • Coupon: choose Specific Coupon from the drop-down.
  • Coupon Code: you don’t need to enter anything in this field; Klaviyo will automatically generate coupon codes for you.
  • Use Auto Generation: you must enable this field. If you don’t enable this field, Klaviyo will not be able to generate coupon codes. 
  • Uses per Coupon: the number of times your coupon can be used; usually this value will be 1.
  • Uses per Customer: the number of times your coupon can be used per customers; usually this value will be 1.
  • From -- To: enter the date range during which the coupon will be valid; the To date will be the coupon's expiration date.

The new cart price rule menu where you can fill in your desired rule information.

4. At the bottom of your New Cart Price Rule screen, you’ll see additional settings. Conditions, Actions, and Labels settings are optional and will impact how coupons are applied in your Magento 2 store; these won’t affect Klaviyo Coupon generation.

The optional Conditions, Actions, and Labels settings located at the bottom of the new cart price rule page.

5. Manage coupon codes: these settings don’t need to be filled in. When Klaviyo generates coupon codes, those codes will appear in this section. 

6. When you’re finished, click Save on the upper right corner of your screen.

The save button highlighted in the upper right corner of the new cart price rule page.

7. View your list of Magento 2 coupons. Each Magento 2 coupon is associated with an ID. Take note of the ID of the coupon you created. You’ll need it in the next step.

The list view of your Magento 2 coupons with the ID of the coupon you created circled.

Create a Magento coupon in Klaviyo

Next, you’ll create a coupon in Klaviyo. For this step, you need the ID associated with the price rule you just created in your Magento 2 account. A new coupon created in Klaviyo must reference a pre-existing Price Rule in Magento.

1. Navigate to your Coupons section and select Magento 2 Coupons.

The coupons tab with Magento 2 coupons selected.

2. Click Add Coupon to create a new coupon. 

3. Enter a name for your coupon in the Coupon Name field, and enter the Magento 2 price rule ID associated with this coupon. Again, you need to have created a price rule in Magento 2 before you create a coupon in Klaviyo. Head back to your Magento 2 account if you need to reference this ID number again. 

4. When you're finished click Add Coupon.

The modal asking for the name of your newly created coupon and its Magento 2 rule ID.

5. You’ve created your new coupon.

Use a Magento coupon in a flow email

Once a coupon is created, you can insert it into a flow email. Note that you can only use 1 coupon code per email. Also, you can display the same coupon code in multiple places, but you cannot use multiple codes.  

To insert a coupon into your flow email, use the following placeholder variable:

{% coupon_code 'CouponName' %}.

Replace CouponName with the name of the coupon. For example:

An example email template with the placeholder variable, which has CouponName replaced by the name of your coupon, included in your content.

Using coupons in SMS flow messages

Unique coupons are also available for your SMS/MMS messages in flows. Generate the codes just like you would for email. Then, use the template tag below to add the coupon code to your SMS or MMS message:

{% coupon_code 'CouponName' %}.

In the snippet, change CouponName to the name of the coupon you want and add it into the message.

An example SMS messase with the unique coupon included in the message content, and the name of your coupon included in the code snippet.

You can only use 1 coupon code per SMS message. If you try to use more than 1, you will receive the following error. 

The error message that populates in the editor if you try to include more than one unique coupon in an SMS message.

Additional resources


Was this article helpful?
99 out of 140 found this helpful