Getting started with Magento 2.x (CE and EE)

Estimated 15 minute read
|
Updated Sep 12, 2024, 3:48 PM EST
You will learn

You will learn

Learn how to integrate Klaviyo with your Magento 2 CE or EE store. You'll need to install the Klaviyo extension in Magento, configure the extension and set up OAuth, then enable the integration in Klaviyo. This guide covers all required integration steps, as well as how to confirm your historical data sync is successful. 

Before you begin

Before you begin

Please note that Magento 2 versions below 2.2.0 are not supported.

To ensure that Klaviyo can make the necessary API calls for integration, your Magento 2 server must have a publicly accessible hostname. Magento 2 servers hosted locally will be unable to fully integrate with Klaviyo.

Find your Klaviyo extension version

Find your Klaviyo extension version

All version ranges in the table are inclusive. All extensions are available for installation via Composer. 

Magento 2 VersionKlaviyo Extension Version
2.4.0+

4.1.0+

2.3.4+

3.0.11-patch

2.3.0 - 2.3.3

3.0.4-patch

2.2.0 - 2.2.11

2.2.0-patch

Below 2.2.0

Not supported

The installation process differs depending on which Magento 2 version you’re using. 

If you're using Magento 2 version 2.4.0 or above, follow the instructions detailed in Install with Composer below.

For those on Magento 2 versions below 2.4.0: We have released patches to bring compatibility between older versions of our extensions and our new APIs. Github links are provided in the table above, and they're also available for install via Packagist/Composer. You’ll need to install via whatever method you currently use to install extensions (if that's Composer, you can follow the Install with Composer section below). If you're using Magento 2 version 2.2.0, you'll also need to manually Enable OAuth after installation.

Install the Klaviyo extension in Magento 2

Install the Klaviyo extension in Magento 2

How-to video

How-to video

Install with Composer

Install with Composer

Installation via Composer requires an IT administrator with SSH access to the server where Magento 2 is hosted. 
  1. Log in to your Magento 2 server and navigate to the root directory of your Magento app from your command line tool. This guide shows example outputs for Terminal, but these steps can be modified for any command line tool of your choice.
  2. Run the following command to access the latest version of the Klaviyo extension from Packagist. Packagist is a repository for PHP code libraries which allows you to easily install the latest version of the extension.
    composer require klaviyo/magento2-extension
  3. If you need to install an older version of the Magento 2 extension with Composer, specify the version you wish to install. For example:
    composer require klaviyo/magento2-extension:3.0.4-patch composer1.png
  4. Run the following command to enable the Klaviyo extension you just downloaded:
    php bin/magento module:enable Klaviyo_Reclaim --clear-static-contentcomposer2.png
  5. As displayed in the sample output, you must now enable any additional modules. Run the following command to enable them:
    php bin/magento setup:upgrade
  6. Scan the output for Module 'Klaviyo_Reclaim' to confirm that the Klaviyo module is enabled and running.
  7. To ensure that the CSS and JS on your Magento 2 store continues to work properly, you’ll need to run a static content deploy command.
    php bin/magento setup:static-content:deploy -fcomposer3.png
  8. You can now return to the Magento admin dashboard from your browser.

Installation via Composer is complete! Proceed to the next section for configuration instructions.

Configure the Klaviyo extension

Configure the Klaviyo extension

How-to video

How-to video

  1. In your Klaviyo account, navigate to the API keys tab.
  2. In a new tab, navigate to your Magento store admin.
  3. Under Settings, click Stores > Configuration.
  4. From the Klaviyo dropdown, click General.
  5. Set Enable Klaviyo Extension to Yes.
  6. Copy your six-digit Klaviyo public API key from the API keys tab and paste it in the corresponding box in Magento.
  7. On the Klaviyo API keys tab, generate a new private key and then paste it into the corresponding box in Magento. Authenticating with your private API key will allow you to sync Newsletter subscriptions from Magento to Klaviyo.

In the next section, you'll set up OAuth, which enables other aspects of the integration.

Set up OAuth

Set up OAuth

Next, you'll enable OAuth authentication to securely connect your Klaviyo account to the Magento 2 extension. We have a separate guide for those with an existing integration who need to add OAuth. If you're using Magento 2 version 2.2.0, visit our guide on manually enabling OAuth for your integration

  1. Navigate to the Setup OAuth tab in Magento.
  2. Give your integration a memorable name, as you will need to locate it by this name later.
  3. Click Save Config to proceed.
    OAUTHtab.png
  4. Locate System in the left hand navigation pane and select Integrations from the System tray.
  5. Locate your integration name and click Activate. Activating the integration will open up a window requesting you to approve access.
    activateoauth.png
  6. Click Allow to be redirected to Klaviyo, where you'll complete the integration setup.
    oauthperms.png
  7. Sign in to Klaviyo if prompted, or confirm your account name is correct and click Integrate. This will add the Magento 2 integration to the Klaviyo account associated with the API key you used for setup. If you are logged into multiple Klaviyo accounts and the correct account is not displaying, log out of any other sessions.

If the window closes automatically, the connection was successful. You can also confirm success by opening your Klaviyo account in a new browser tab or window, clicking your account name in the lower left corner, then selecting Integrations and looking for Magento 2 on the list.

If you receive the following error instead, ensure that the API keys used in the first step correspond to the account you're currently logged in to.
apierror.png

When establishing the connection between Magento and Klaviyo, if you receive a list of errors instead, you can click each error to learn more about the cause.

oauthgenerror.png

Set a newsletter list

Set a newsletter list

Next, you'll select a Klaviyo list to sync your newsletter subscribers to. You also have the option of using Klaviyo opt-in settings or Magento 2 opt-in settings for your chosen list.

  1. In Magento, click Newsletter.
  2. Select the Klaviyo list you want to sync your Magento sign-up form to from the dropdown.
  3. Click Save Config.

newsletterm2.png

Enable consent at checkout

Enable consent at checkout

Next, you can choose to enable consent at checkout for email and SMS.

Please note that if you enable consent at checkout, you'll also need to enable webhooks (below) in order for consent at checkout to function properly. 

  1. On the Configuration page, under Klaviyo, navigate to Consent at Checkout.
    m2cac-new.png
  2. You’ll see a section for collecting email consent and SMS consent. The two are treated separately, so that you can collect just email, just SMS, or both. If you gather both SMS and email subscribers, choose a different list for SMS than for email. This makes sure that consent will always be properly attributed to the correct channel.
    • Consent will not sync (for both email and SMS) until the customer finishes placing the order and, if applicable, confirms their subscription due to double opt-in.
    • Note that for users already logged in to your Magento 2 store, the email consent checkbox will not appear at checkout by default.
  3. Under Email, select Yes for Subscribe contacts to email marketing at checkout.
  4. Select an email list to sync subscribers to, such as a newsletter.
  5. Enter the email opt-in checkbox text you wish to use.
    2021-03-24_13-00-56.png
  6. Under SMS, select Yes for Subscribe contacts to SMS marketing at checkout.
  7. Choose the list you want your SMS contacts to sync to. For additional detail regarding these settings, check out our guide to collecting SMS consent at checkout.
    m2smscac.png
  8. Sort order allows you to change the placement of the email and SMS consent boxes. By default, these boxes appear under the first email input and shipping phone number field, respectively. Thus, if you haven’t rearranged the checkout page, you do not need to change the sort order. If you have changed the layout, adjust the sort order accordingly.
  9. When you are finished, click Save Config in the upper right.
Enable webhooks

Enable webhooks

Next, you'll enable Klaviyo webhooks in your Magento 2 account. Please note that enabling webhooks is required for consent at checkout to function correctly. 

  1. From the admin dashboard, navigate to Stores > Configuration.
  2. Click on Klaviyo and select the Webhooks tab. 
  3. Create a webhook secret and enter it into the corresponding Webhook Secret field. The webhook secret is a key that Klaviyo will use for validation. This secret can be anything you choose, but we recommend creating a secure string of letters and numbers. Magento will hide your webhook secret with asterisks for security purposes, so be careful to enter it correctly.
    m2webhooktab.png
    If you are using a multi-store integration, the webhook secret in this field should be entered in your default configuration, and the same secret will be used as validation for each store configuration. The webhook secret should only be added to the default config and should not be added per store.
  4. Next to the webhooks you wish to enable, select Yes from the dropdown. To read more about the webhooks supported by Klaviyo, check out our guide to webhooks for Magento 2.
  5. Click Save Config.
Enable the Magento 2 integration in Klaviyo

Enable the Magento 2 integration in Klaviyo

How-to video

How-to video

  1. Open Klaviyo, click your account name in the lower left corner, then select Integrations. Find Magento 2 on the list and select it.
  2. On the next page, you'll have the option to add new Magento 2 customers to a Klaviyo list. Click the checkbox to Add new Magento 2 customers to a Klaviyo list and select a list from the dropdown. Note that checking this setting will only add customers to the selected list, but not subscribe them to marketing messages.

    This setting will only sync new customers; existing customers need to be manually migrated from your Magento list to Klaviyo.
  3. Under Advanced, enable the following settings as needed: 
    • Stores
      All Magento 2 stores are synced to Klaviyo by default. This setting allows you to be selective about which stores you integrate with. Head over to Supporting multiple Magento stores to learn more. 
    • Special price settings
      This setting refers to a special sale price for items that can optionally take effect in a certain date range. We highly recommend enabling this feature if you're planning to use it, as it's more difficult to enable later. When you enable Use special price for product prices when applicable, the product block will display the special price when applicable. When using a dynamic product feed, the special price will populate at send time. When manually selecting items from your catalog, the special price will populate once you select the product(s). For each product, there are 4 metadata fields that will sync:
      • price
        (Required, float) The standard price of the item.
      • special_price
        (Optional, float) This is a special sale price for the item. When this price is in effect, you will see this special_price next to a strikethrough of the price.
      • special_from_date
        (Optional, date) This specifies a start date for special_price to take effect.
      • special_to_date
        (Optional, date) This specifies an end date for special_price being in effect.
    • Custom Media Root URL
      This setting allows you to change the default path for your site images. Enable this setting if you host your product images on a URL that is different than your website. 
  4. Click Save.

You've now successfully enabled the Magento 2 integration! Your data will begin to sync to Klaviyo in minutes. 

After the initial historical data sync is complete, the Magento 2 integration syncs every 30 minutes.

Data synced with the Magento 2 integration

Data synced with the Magento 2 integration

Klaviyo's Magento 2 integration pulls key customer information from your Magento platform.

Here is some of the data we sync from Magento:

  • Customer information including first name, last name, and location.
  • Sales and order data including which items were purchased, item images, item categories, and any discounts applied.
  • Fulfillment, refunded, and canceled order data.
  • When people visit your website and which items they view; web tracking is handled by the extension.

To learn more, head over to our Magento 2 data reference

Convert Magento order values into a single currency

Convert Magento order values into a single currency

Klaviyo supports the conversion of all foreign currencies in Magento to one primary currency in Klaviyo - please contact support to enable this feature. This is especially helpful if you have multiple stores with transactions in different currencies.

When this feature is enabled:

  • The conversion happens when Magento syncs order data into Klaviyo. 
  • Klaviyo will check if the order_currency_code is the same as the set global_currency_code. If not, Klaviyo will convert the order total from the order currency to the global currency specified to ensure that your financial analytics are accurate. Please note that order line items will remain in the order currency code and not be converted. 
Upgrade your extension

Upgrade your extension

Consult the table below: are you using an extension version below the one specified for your Magento 2 version? If so, we recommend upgrading your extension immediately. Certain older versions of the extension use Klaviyo’s v1 and v2 APIs which are retired and no longer operate as expected. We provide specific patched versions to assist customers on older versions of Magento 2, which are linked in the table.

First, determine what extension version you need to upgrade to using the table below. 

All version ranges in the table are inclusive. All extensions are available for installation via Composer. 

Magento 2 Version

Current Klaviyo Extension Version 

Upgrade Klaviyo Extension Version

2.4.0+

4.1.0+

No upgrade needed

2.4.0+

4.0.0 - 4.0.12

4.1.0+

2.3.4+

3.0.5 - 3.0.11

3.0.11-patch

2.3.0 - 2.3.3

3.0.4

3.0.4-patch

2.2.0 - 2.2.11

2.2.0

2.2.0-patch

Below 2.2.0N/ANot supported

Now that you’ve determined what version to upgrade to, it’s time to upgrade. The upgrade process differs depending on which Magento 2 version you’re using. 

If you are using Magento 2 version 2.4.0 or above, follow the instructions detailed in Install with Composer above and run the command to install the latest version. This will overwrite your current version and your update will be complete - there’s no need to re-configure the extension or re-enable the integration in Klaviyo.

For those on Magento 2 versions below 2.4.0: We have released patches to bring compatibility between older versions of our extensions and our new APIs. Github links can be found in the table above, and they're also available for install via Packagist/Composer. You’ll need to install via whatever method you currently use to install extensions (if that's Composer, you can follow the Install with Composer section above).

Additional resources

Additional resources

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.
Live training
Join a live session with Klaviyo experts to learn about best practices, how to set up key features, and more.
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