---
title: "How to set up coupons for Magento 2"
description: "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."
canonical_url: "https://help.klaviyo.com/hc/en-us/articles/360041971851"
markdown_url: "https://help.klaviyo.com/hc/en-us/articles/360041971851.md"
locale: "en-us"
category: "Content"
section: "Coupons and ecommerce integrations"
updated: "2026-10-26"
---

# How to set up coupons for Magento 2

## 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.](https://docs.magento.com/user-guide/marketing/price-rules-cart.html)

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. Set up a price rule in Magento 2.

2. Create the coupon in Klaviyo.



**📝 Note:** If you would like to send campaign emails with unique coupon codes for Magento 2, follow this guide on [uploading unique coupons into Klaviyo](https://help.klaviyo.com/hc/en-us/articles/115005084727.md#h_01HMW7FB2WV5RT1T0EZ3N7TMJ9) and using them in a message.

## 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](https://help.klaviyo.com/hc/en-us/articles/115005254348.md).

## Set up a price rule in Magento 2

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

🎬 [Watch video on Wistia](https://klaviyo.wistia.com/medias/mbqh9crj11)

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

![The cart price rules menu in magento 2 with add new rule selected.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/16c00c4df6fb9e35f712aeeb9a560c199259f91d-1019x323.jpg?auto=format)

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 customer; 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.



**📝 Note:** Coupons set to never expire will still show an expiry date of 1 year listed in Klaviyo. However, they will not expire.

![The new cart price rule menu where you can fill in your desired rule information.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/3634905e6848b8802d3e1706f748bc3bc40261da-933x1658.jpg?auto=format)

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.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/bb170df0fc0a2693bb84e01ef27a97817ea5008a-936x394.jpg?auto=format)

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** in the upper right corner of your screen.

![The save button highlighted in the upper right corner of the new cart price rule page.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/fb66c02a78fbb2d93ef86a8166bde849aadc45bd-991x235.jpg?auto=format)

7. Return to your list of cart price rules in Magento 2 and note the ID of the rule you created. You’ll need this rule ID to create the coupon in Klaviyo.

![The list view of your Magento 2 coupons with the ID of the coupon you created circled.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/efc7982b52b27df897dfd18c753a7c03b1b1d857-984x524.jpg?auto=format)

## 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 **Content > Coupons** section and select **Magento 2 Coupons**.

![The coupons tab with Magento 2 coupons selected. ](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/860449d96f44c6c6107676b9341d094b8bd4a7db-2132x663.jpg?auto=format)

2. Click **Create Magento 2 Coupon** to create a new coupon. 

3. Enter a name for your coupon in the **Name** field. Use letters, numbers, or underscores, with a maximum of 32 characters. In **Magento 2 rule ID**, enter the ID of the price rule you created in Magento 2. You must create the price rule before creating the coupon in Klaviyo; return to your Magento 2 account if you need to look up its ID.

4. When you’re finished, click **Create coupon**.

![The modal asking for the name of your newly created coupon and its Magento 2 rule ID.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/ddf10f20f9affe5cae9e87ab28851e078f367b97-2090x748.jpg?auto=format)

Your new coupon appears on the **Magento 2 Coupons** tab.

## Use your unique coupon in a flow

Once you’ve created and configured your coupon, insert it into a flow message.

1. Navigate to the **Flows** tab in Klaviyo’s left-hand navigation.

2. Open an existing flow or [create a new one](https://help.klaviyo.com/hc/en-us/articles/115002774932.md).

3. Select a flow message inside your flow.

4. Open the message editor for the selected flow message. For an email with an existing template, click **Edit** in its content section. If the email has no template, click **Select template** first.

5. Click in the text field where you want the coupon to appear, then click the personalization icon. Depending on your editor, you may see a person icon, or a button labeled **Personalization**. 




![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/3f075a342b2c1da2d8c0bae5782013d10fe7f136-332x232.png?auto=format)

6. From the *All types* menu, select **Coupons**. 




![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/7cd63ec8b0167063403344ac0184f7b5fd3d3a7f-658x914.png?auto=format)

7. Select the coupon you'd like to add.

8. Return to the flow builder after saving your message content. In the drag-and-drop email editor, open the 3-dot menu beside **Exit** and select **Return to Flow**.

9. Optional: In the flow builder, select your flow email, open the 3-dot menu in its content section, and click **Preview email**. When you preview the email directly in Klaviyo, you’ll see your coupon’s name followed by “-PREVIEW” instead of a unique code. Klaviyo assigns a real code when the flow message sends.



![An example email with a coupon tag shown in preview mode.](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/c0064a5e2f911fa27d4614cef6bc761bf001e2cf-962x530.jpg?auto=format)

When a flow message sends, a unique 10-character alphanumeric discount code replaces the coupon tag for each recipient. If you include the same coupon tag in multiple flow messages, the recipient receives the same assigned code as long as it has not expired in Klaviyo.

![Unqiue 10 digit code added to the end of coupon prefix](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/430ed8f7a15ae8c144449956b4390450da1ed214-1206x578.jpg?auto=format)

Klaviyo requests a new code from Magento 2 at send time when the recipient does not already have an unexpired code assigned for that coupon. You do not need to set a minimum inventory or manually add batches of codes for Magento 2 flow messages.

When your message is ready to send automatically, set its status to **Live**. See [Getting started with flows](https://help.klaviyo.com/hc/en-us/articles/115002774932.md) for instructions on changing flow message statuses.

## Additional resources

- [How to set up coupons (for Magento 1.x)](https://help.klaviyo.com/hc/en-us/articles/115005246547.md)

- [How to view coupon history](https://help.klaviyo.com/hc/en-us/articles/360048069712.md)

- [Troubleshooting your Magento 2 integration](https://help.klaviyo.com/hc/en-us/articles/5510750923035.md)
