Klaviyo's Magento 1 integration is no longer accepting new installations and will reach full end-of-support in late 2027. Klaviyo Support is no longer able to assist with Magento 1–related requests.

You will learn

Magento supports Shopping Cart Price Rules that can be used to apply a discount to a customer's order. Coupon codes can be created for existing price rules, so shoppers can use a code to apply a discount during checkout.

Klaviyo's Coupons for Magento feature allows stores with an existing Magento 1.x integration to do the following:

  • Create new coupons in Klaviyo associated with pre-existing price rules in Magento.
  • Include dynamic coupons in email and SMS/MMS flow messages, so each recipient receives a unique code.

This guide will explain how to get set up with Magento coupons in Klaviyo.

Magento-generated dynamic coupons are available in email and SMS/MMS flow messages. They are not available in campaign emails. Sending unique coupon codes in a campaign can require thousands of codes per second, and Magento server rate limits can affect code generation at that volume.

Requirements

These steps require an existing, enabled Magento 1 integration and the Klaviyo extension installed in Magento. For details about the data synced by the integration, see the Magento 1 data reference.

Enable the REST API

Start by enabling the REST API by creating a new REST Role and giving it full access, then assigning the role to one of your admin users.

  1. Click on System > Web Services > REST - Roles.
  2. Create a new Admin role. For the field Role Name enter a name, for example "Administrator".
  3. Click on the Role API Resources tab on the left. Set Resource Access to All and click Save Role.
  4. Next, navigate to System > Web Services > REST - Attributes.
  5. Select Admin from the list of user types.
  6. Set Resource Access to All and click Save.
  7. Next, navigate to System > Permissions > Users.
  8. Select an admin user from the list and click Edit user.
  9. Click the REST role tab on the left sidebar.
  10. Click the radio button to assign the new REST admin role to your user.
  1. Click Save User.

You've now enabled the REST API for your Magento store.

If you are unsure whether or not your REST API is configured properly, please review the steps outlined in our resource on troubleshooting coupons for Magento 1x.

Generate REST credentials in Magento

To enable Klaviyo's Magento Coupons feature, generate REST API credentials using the admin user you assigned the REST role to, then enter them in Klaviyo.

  1. Log in as the admin user you assigned the REST role to in the Enable the REST API section above.
  2. Click on System > Configuration and then click on Klaviyo under the Customers section.
  3. Click Generate OAuth Tokens.
763276
763276

The Consumer Key, Consumer Secret, Authorization Token, and the Authorization Secret will populate. You will copy/paste these values into your Klaviyo account in the next step.

Set up Magento coupons in Klaviyo

Your Magento server must support HMAC-SHA1 signatures for OAuth authentication.

  1. From your Klaviyo account, navigate to your Magento integration.
  2. On the Settings tab, go to Advanced > Coupons and select Activate coupons.
  3. Enter your Consumer key, Consumer secret, Authorization token, and Authorization secret from Magento.
  1. Click Save.

After the settings save successfully, you can create a coupon from the Coupons page.

Create a Magento coupon in Klaviyo

Open the Coupons page in Klaviyo and select the Magento 1 Coupons tab.

Before you create a new coupon, you will first need to define a Price Rule in Magento that will include all the specifications for the coupon. Price Rules cannot be created from within Klaviyo. A new coupon created in Klaviyo must reference a pre-existing Price Rule in Magento.

When creating a Price Rule in Magento, note that the option to associate a new Price Rule with a specific coupon should be left set to Specific Coupon and you must have the Use Auto Generation checkbox selected.

  1. Click Create Magento 1 Coupon.
  2. Enter the Name and Magento rule ID:
    • Name: Use a unique name with only letters, numbers, and underscores, up to 32 characters long. You cannot change the name after creating the coupon.
    • Magento rule ID: Enter the ID of the price rule you created in Magento to associate it with this coupon.
  3. Click Create coupon. After creation succeeds, Klaviyo returns you to the Magento coupon list.

After creation, you can review the following details in Klaviyo:

  • Coupon: The coupon name in the list.
  • Active timeframe: Open the coupon to see the dates supplied by its Magento price rule. The timeframe can show:
    • Active, No Expiration
    • Date A - No Expiration
    • Date A - Date B
    • Expires Date B
  • Created: The date the coupon was created.
  • Last Updated: The date the coupon was last updated.

To edit a coupon, click its name, update the Magento rule ID, and click Update coupon. To delete a coupon, open its row menu, select Delete, and confirm the deletion.

Use a Magento coupon in a flow email

Once a coupon is created, insert it into a flow email using the following template tag. To display the same code in multiple places, repeat the tag with the same coupon name.

text
{% coupon_code 'CouponName' %}

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

mceclip0__2_.png
mceclip0__2_.png

Using the same coupon in an email and an SMS/MMS flow message lets Klaviyo reuse the code already assigned to that recipient. Repeating the coupon name does not guarantee a new code for each message.

Use unique 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 your coupon and add the snippet to your SMS or MMS flow message.

2020-06-16_17-58-37.png
2020-06-16_17-58-37.png

You can use 1 coupon name per SMS/MMS message. If you add different coupon names, you will see an error. In email, you can use show/hide blocks to send different coupons based on where someone lives or what they’ve done. To show 1 offer per recipient, set the conditions so only the intended coupon block appears.

2020-06-17_09-51-08.png
2020-06-17_09-51-08.png

Troubleshoot errors

Unable to activate coupons or connect to the REST API

You may see “Unable to activate coupons due to an authentication issue” in the integration settings, or “Unable to connect to the REST API with the specified REST credentials. Please check that these credentials are valid in your Magento admin.”

First, check that all 4 REST credentials were copied correctly. If they are correct, check these possible causes:

  1. Your Magento server is not set up to support HMAC-SHA1 signatures for OAuth authentication.
  2. You may not have enabled full role access for the REST API.

Confirm that your Magento server supports HMAC-SHA1 signatures for OAuth authentication. Then check the following REST permissions and server settings:

  1. Uncomment, or add, the rewrite rule in your .htaccess file. This is the line you’ll want to ensure is un-commented:
    RewriteRule ^api/rest api.php?type=rest [QSA,L]
  2. Check that your REST role is set up correctly.
    Follow the steps in the Enable the REST API section above.
  3. If you use Apache, check that it passes the Authorization header to PHP. The Magento REST connection uses OAuth credentials. See this guide to passing the Authorization header for server configuration details.

If the error specifically mentions an SSL certificate, check that your Magento store has a valid, trusted SSL certificate installed.

All recipients receive the same coupon code

When creating a Price Rule in Magento, the option to associate a new Price Rule with a specific coupon should be left set to Specific Coupon and you must have the “Use Auto Generation” checkbox selected.

Click on your Price Rule in Magento, and under General Information, scroll down to the line option "Coupon" and change this setting to "Specific Coupon". Next, check the box for auto generation here. This should fix the issue and allow us to generate a new unique coupon code for each email recipient.

Was this article helpful?
Use this form only for article feedback. Learn how to contact support.

Explore more from Klaviyo

Community
Connect with peers, partners, and Klaviyo experts to find inspiration, share insights, and get answers to all of your questions.
Partners
Hire a Klaviyo-certified expert to help you with a specific task, or for ongoing marketing management.
Support

Access support through your account.

Email support (free trial and paid accounts) Available 24/7

Chat/virtual assistance
Availability varies by location and plan type