Set Up Coupons (for Magento 1.x)

Overview

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 that shoppers can easily leverage a given code to apply a discount during the checkout process.

Klaviyo's Coupons for Magento feature allows Magento 1.0 stores to do the following:

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

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

Requirements

Ensure that the following requirements are in place before setting up coupons for Magento:

Note

If you are unsure whether or not your REST API is configured properly, please review the steps outlined under the first subheader of our Troubleshooting section at the end of this guide.

Generate REST Credentials in Magento

To enable Klaviyo's Magento Coupons feature, first generate REST API credentials from your Magento store, and then paste these into your Klaviyo account.

  1. Click on System > Configuration and then click on Klaviyo under the Customers section.
  2. Click Generate OAuth Tokens.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.

Setup Magento Coupons in Klaviyo

  1. From your Klaviyo account, navigate to your Magento integration.
    763277
  2. Click the Advanced Options arrow to expand the Coupon Settings.
  3. Paste in the REST credentials you created above.

    Note

    Your Magento server must support HMAC-SHA1 signatures for OAuth authentication.
    763278
  4. Click Update Magento Settings.

Klaviyo will validate your REST credentials and you will be able to start creating coupons with the Coupons tab of your account.

Create a Magento Coupon in Klaviyo

When you first navigate to the Coupons tab in your Klaviyo account after providing your REST credentials, you will see the message, "You haven't added any coupons yet." 

Note

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 Add Coupon to create a new coupon.
  2. Fill in the following information: Coupon Name and the Magento Rule ID.
    • Coupon Name: The name you specify can consist of only letters, numbers and underscores and can be up to 32 characters long
    • Magento Rule ID: Create a rule in Magento first, and paste the ID of that rule here to associate it with this coupon

763280

All created coupons will appear with the following overview details:

  • Coupon Name: Name of the coupon
  • Active Timeframe: There are the following options:
    • Active, No Expiration
    • Date A - No Expiration
    • Date A - Date B
    • Active, Expires Date B
  • Created Date: Date the coupon was created
  • Last Updated Date: Date the coupon was last updated

Coupons can be edited and deleted from this tab via the dropdown on the right-hand side.
763282

Use a Magento Coupon in a Flow Email

Once a coupon is created, you can insert it into a flow email using the following placeholder variable:

{% coupon_code 'CODE_FOR_YOUR_COUPON' %}

where you replace CODE_FOR_YOUR_COUPON with the coupon name.  For example:

763284

When emails are sent out, this variable will be dynamically replaced with a unique discount code for each recipient.

Note

When you preview  emails - either in Klaviyo, or by sending a preview email - you will not see a unique coupon code populate. Coupon codes are only generated during live sends.

Troubleshooting

Getting error message, or error page, when trying to save your REST API credentials and update Magento Integration settings in Klaviyo.

There are a few possible root-causes -- this issue means we’re getting a 404 response from Magento when trying to hit the /api/rest/products endpoint for your Magento instance. This suggests something isn't set up quite right for your REST API to be working. Possible problem areas: your Apache configuration is incorrect, file permissioning isn't correct, .htaccess files not existing in folders etc.

Please try the following troubleshooting steps:

1. Un-comment, 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. Enable full role access for the REST API

  • Set up permissions for REST resource operations from Magento Admin Panel
    • Navigate to System -> Web Services -> REST Roles
    • Create new Admin role -- in the field “Role name” enter for example “Administrator”
    • Click on “Role API resources” tab on the left -- “Role Resources” screen is shown, choose "All" and Save Role
  • Configure resource attributes and access permissions
    • Navigate to System-> Web Services -> REST attributes
    • Click on “Admin”
    • Under “User type resources” screen, select “All“ and Save
  • Assign configured Admin REST Role to existing admin user
    • Navigate to System-> Permissions-> Users
    • Click on some admin user from list in order to open “Edit user” screen
    • There is a tab named “REST role” on the left -- click on it and a list of Admin type roles is shown on the screen
    • Click on “Assigned” radio box near the new Admin role you created and Save User

Error Message: “Unable to connect to the REST API with the specified REST credentials. Please check that these credentials are valid in your Magento admin."

If you are seeing this error message in Klaviyo, there are two likely root causes:

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

To resolve this issue, enable HMAC-SHA1 signatures for OAuth authentication on your Magento server. Then complete the following steps to update your REST permissions:

1. Set up permissions for REST resource operations from Magento Admin Panel

  • Navigate to System -> Web Services -> REST Roles
  • Create new Admin role -- in the field “Role name” enter for example “Administrator”
  • Click on “Role API resources” tab on the left -- “Role Resources” screen is shown, choose "All" and Save Role

2. Configure ACL Attributes Rules and access permissions

  • Navigate to System-> Web Services -> REST attributes
  • Click on “Admin”
  • Under “User type resources” screen, for Resource Access select “All“
  • Save

3. Assign configured Admin REST Role to existing admin user

  • Navigate to System-> Permissions-> Users
  • Click on some admin user from list in order to open “Edit user” screen
  • There is a tab named “REST role” on the left -- click on it and a list of Admin type roles is shown on the screen
  • Click on “Assigned” radio box near the new Admin role you created and Save User

Coupon codes populated into emails by Klaviyo are not unique -- all recipients appear to be receiving the same 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?
0 out of 0 found this helpful