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

read
Last updated at:

Overview

Klaviyo integrates with both Magento 2 CE and Magento 2 EE. This guide covers all required steps to integrate with Magento 2 stores, as well as how to confirm your historical data sync is successful. After your integration setup is complete, transactional data will sync every 30 minutes.

If you are installing the integration for the first time, please follow the installation instructions for your Magento 2 version.

Customers using Magento 2 version 2.2.0 and older are required to manually enable OAuth after installation. If you are using v2.2, first Install with Web Setup Wizard then Manually Enable OAuth.

What version of the extension do I need?

Magento 2 Version Klaviyo Extension Version
2.4.0+

4.0.0+

2.3.4+

3.0.5 (minimum)
3.0.11 (maximum)

2.3.0 - 2.3.3

3.0.4

Below 2.3.0

2.2.0

Install the Klaviyo extension in Magento 2

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.

How-to video

Install with Composer (2.4+)

Installation via Composer requires an IT administrator with SSH access to the server where Magento 2 is hosted. To install the Klaviyo extension, you’ll need to execute four commands.

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 plugin.

composer require klaviyo/magento2-extension

If you need to install an older version of the Magento 2 extension with Composer, specify the version you wish to install. To determine what version you need to install, review the chart. For example:

composer require klaviyo/magento2-extension:3.0.4

composer1.png

3. Run the following command to enable the Klaviyo extension you just downloaded:

php bin/magento module:enable Klaviyo_Reclaim  --clear-static-content

composer2.png

4. 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

5. Scan the output for  Module 'Klaviyo_Reclaim' to confirm that the Klaviyo module is enabled and running.

6. 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 -f

composer3.png

7. You can now return to the Magento admin dashboard from your browser.

Installation via Composer is complete! Skip the following section, Install with Web Setup Wizard, and proceed to the instructions for configuring the Klaviyo extension.

Install with Web Setup Wizard (2.3 & Older)

1. The Klaviyo Extension adds web tracking and viewed product tracking to your Magento store. To prepare, log in to the Magento Marketplace and add the free Klaviyo Extension to your account.

For compatibility with your Magento 2 version, users on version 2.3.0 to 2.3.3 must download Klaviyo extension version 3.0.4. Users on Magento 2 version 2.3.4+ must download Klaviyo extension version 3.0.5 or later.

2. Log in to your Klaviyo account and write down your public API key, which will be needed in the following steps.

3. From your Magento store admin page, click System, then click Web Setup Wizard.

4. In the Web Setup Wizard click Extension Manager.

image__1_.png

5. If you haven't already, sign in and sync to your Magento Marketplace account.

6. Locate the Klaviyo extension under the name klaviyo/magento2-extension.

7. In the Actions column, click the Select dropdown and choose Install.

extenisonmanager.png

8. Then, proceed to configuring the Klaviyo extension.

Configure the Klaviyo extension

How-to video

1. After the installation is complete, with your Klaviyo public API key in hand, navigate to your Magento store admin.

2. Click Stores and then Configuration under Settings.

3. From the Klaviyo dropdown, click General.

4. Set Enable Klaviyo Extension to Yes and enter your six-digit Public Klaviyo API Key.

m2generaltab.png

Setup OAuth

Next, you'll enable OAuth authentication to securely connect your Klaviyo account to the Magento 2 extension. Visit the guide here if you have an existing integration and need to add OAuth. If you are using Magento 2 version 2.2.0, visit the guide here to manually enable OAuth for your integration.

5. Navigate to the Setup OAuth tab.

6. Give your integration a memorable name in the Name field, you will need to locate it by this name later.

7. Click Save Config to proceed.

OAUTHtab.png

8. Locate System from the left hand navigation pane and select Integrations from the System tray. 

9. Locate the integration with the name you used above and click Activate.

activateoauth.png

Activating the integration will open up a window requesting you to approve access.

10. Click Allow to be redirected to Klaviyo to complete the integration setup.

oauthperms.png

11. Sign in if you have not already done so, or confirm your account name and ID are correct and click Integrate Magento 2. This will add the Magento 2 integration to your 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.

m2authorize.png

If the window closes automatically, the connection was successful. You can also confirm by opening your Klaviyo account in a new browser tab or window and checking the integration’s settings from the Integrations tab.

If you receive the following error instead, ensure that the API keys used in the first step correspond to the account you are 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

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

12. Click Newsletter. From the dropdown, select the Klaviyo list you want to sync your Magento sign-up form to.

13. Click Save Config.
newsletterm2.png

Enable consent at checkout

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

A webhook secret is required for consent and validation, as well as to enable webhooks. 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.

14. On the Configuration page, navigate to Consent at Checkout under Klaviyo.

m2cac-new.png

There, 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. 

15. Under Email, select Yes for Subscribe contacts to email marketing at checkout.

16. Select an email list to sync, such as a newsletter.

17. Enter the email opt-in checkbox text you wish to use.

2021-03-24_13-00-56.png

18. Under SMS, select Yes for Subscribe contacts to SMS marketing at checkout.

19. 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

20. 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.

21. When you are finished, click Save Config in the upper right.

Enable webhooks

Next, you'll enable the Klaviyo webhooks in your Magento 2 account.

22. From the admin dashboard, navigate to Stores > Configuration.

23. Click on Klaviyo and select the Webhooks tab.

24. 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.

25. Next to the webhooks you wish to enable, select Yes from the dropdown options. To read more about the webhooks supported by Klaviyo, check out the guide to webhooks for Magento 2.

26. Click Save Config.

Enable the Magento 2 integration in Klaviyo

How-to video

1. If the OAuth setup was successful, under Integration Settings you will see that the integration has been added to your Klaviyo account. Open the Magento 2 integration settings.

2. Next, you have the option of subscribing new customers to a Klaviyo list. Click the checkbox to enable Subscribe new customers to a Klaviyo list and select a list from the dropdown.

m2newsletter.png

This process syncs all future subscribers. Existing subscribers need to be manually migrated from your Magento list into Klaviyo.

3. Click the Advanced Options dropdown. Enable the following settings as needed. If none are required, click Connect to Magento 2 instead.

m2advancedopt.png

  • 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
    We highly recommend enabling Special Price Settings if you're planning to use this feature. It is more difficult to enable this feature later. When configuring your integration settings, you will have the option to pull in "Special Price," which refers to a special sale price for items that can optionally take effect in a certain date range. You can find the Special Price option on the Magento 2 integration page, in the Advanced Options. 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 we 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 Connect to Magento 2.

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

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

Monitor the historical data sync

When you first integrate with Magento 2, Klaviyo will sync the last 90 days of your Magento 2 data so you can get started right away with engaging your most recent customers. After the sync of your most recent 90 days of data, Klaviyo will begin your complete historical data sync. Depending on how many orders, customers and products your store has, it can take anywhere from a few minutes to several days to sync all of your data.

Once this historical sync is complete, new data will sync to Klaviyo every 30 minutes. To check the progress of the initial sync, click on the Metrics tab in the sidebar.

Find the Placed Order metric and change the date range of the graph to see which dates have been fully synced. When the sync is complete, the Magento 2 integration in the Integrations tab will be marked complete. If you want to verify for yourself that all data from Magento 2 is synced, you can cross-check the total orders for a few days or a week. Before you start validating, make sure your account's timezone matches the settings in Magento 2.

To check or update your account's timezone, go to the Account Settings page and check the Contact Information > Organization section.

Data synced with the Magento 2 integration

Klaviyo's Magento 2 integration and complementary extension pull key customer information from your Magento platform.

Klaviyo syncs all customers that subscribe to your Magento 2 newsletter list moving forward. It is important to ensure that any customer that makes it to your Magento 2 newsletter list has consented to receive marketing emails.

Here's 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; you won't have to add the Klaviyo tracking snippet to your site as this web tracking is already handled by our extension for Magento.

To learn more, head over to Review and Understand your Magento 2 Data

Klaviyo limits the number of unique metrics you can create to 200. When you approach this threshold, you will be alerted via a warning in your account, along with an email to the account owner.

Convert Magento order values into a single currency

Klaviyo supports the conversion of all foreign currencies in Magento into one primary currency in Klaviyo. When this feature is enabled, the conversion happens when Magento syncs order data into Klaviyo. This is especially helpful if you have multiple stores with transactions in different currencies.

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 in your integration settings. This ensures that your financial analytics are accurate.

Additional resources

x
Was this article helpful?
334 out of 717 found this helpful