How to Integrate 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.

Install the Klaviyo Extension in Magento 2

Install with Composer (2.4+)

Installation via Composer requires an IT administrator with SSH access to the server where Magento 2 is hosted.

To begin, 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. To install the Klaviyo extension, you’ll need to execute four commands.

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

For compatibility with your Magento 2 version, users on Magento 2 version 2.3.4+ must download Klaviyo extension version 3.0.5 or later.
composer require klaviyo/magento2-extension

composer1.png

Next, run the following command to enable the Klaviyo extension you just downloaded:

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

composer2.png

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

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

Finally, 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

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)

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.

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

From your Magento store admin page, click System, then click Web Setup Wizard. In the Web Setup Wizard click Extension Manager.

image__1_.png

If you haven't already, sign in and sync to your Magento Marketplace account. Then, locate the Klaviyo extension under the name klaviyo/magento2-extension. In the Actions column, click the Select dropdown and choose Install.

extenisonmanager.png

Then, proceed to configuring the Klaviyo extension.

Configure the Klaviyo Extension

After the installation is complete, with your Klaviyo public API key in hand, navigate to your Magento store admin. Click Stores and then Configuration under Settings.

From the Klaviyo dropdown, click General. Set Enable Klaviyo Extension to Yes and enter your six-digit Public Klaviyo API Key.

m2generaltab.png

Then, click Newsletter. From the dropdown, select the Klaviyo list you want to sync your Magento signup form to. Click Save Config.
newsletterm2.png

Enable Consent at Checkout

Next, you can choose to enable consent at checkout for email and SMS. 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. 

Under Email, select Yes for Subscribe contacts to email marketing at checkout. Then, select an email list to sync, such as a newsletter. Enter the email opt-in checkbox text you wish to use.

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

Under SMS, select Yes for Subscribe contacts to SMS marketing at checkout. Next, 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

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.

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. To enable Klaviyo webhooks, navigate to Stores > Configuration from the admin dashboard. Click on Klaviyo and select the Webhooks tab.

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

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.

Click Save Config.

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.

Navigate to the Setup OAuth tab. Give your integration a memorable name in the Name field, you will need to locate it by this name later. Click Save Config to proceed.

OAUTHtab.png

Next, locate System from the left hand navigation pane and select Integrations from the System tray. 

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. Click Allow to be redirected to Klaviyo to complete the integration setup.

oauthperms.png

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. Next, you’ll update the integration settings in Klaviyo. Head over to 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

Enable the Magento 2 Integration in Klaviyo

If the OAuth setup was successful, under Integration Settings you will see a confirmation message OAuth access enabled for this integration

m2intsettings.png

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.

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

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

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.  

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.

x
Was this article helpful?
150 out of 320 found this helpful