# klaviyo/magento2-extension

> Klaviyo extension for Magento 2. Allows pushing newsletters to Klaviyo's platform and more.

`composer require klaviyo/magento2-extension`

Canonical URL: https://packagento.com/klaviyo/magento2-extension

## At a glance

- **Vendor**: klaviyo (https://packagento.com/klaviyo.md)
- **Latest version**: 5.0.0 — released 2026-05-29
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/klaviyo/magento2-extension and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require klaviyo/magento2-extension:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Klaviyo extension for Magento 2. Allows pushing newsletters to Klaviyo's platform and more.

## README

### Features

- **Identifies users**
- **Tracks viewing an item (catalog product)**
- **Saves checkout emails**
- **Sync Newsletter Subscription / Unsubscription to a Klaviyo List**
- **Abandoned Cart information**
- **OAuth Integration Configuration**

For detailed information on Klaviyo extension for Magento 2, visit the [Klaviyo Help center](https://help.klaviyo.com/hc/en-us/sections/360000010571-Magento-2)

### Contributing

We appreciate any and all contributions to this project! Before creating an issue
or raising a PR, review our [Contributing guide](./docs/CONTRIBUTING.md). This guide
reviews issue creation, prerequisites for pull requests, and more.

### Prerequisites

#### Installation and Setup of the Klaviyo extension for Magento 2
-  Follow [this article](https://help.klaviyo.com/hc/en-us/articles/115005254348#overview0) in our Help Center

### Code of Conduct

Read our [Code of Conduct](./docs/CODE_OF_CONDUCT.md) to keep our community approachable
and respectable. Klaviyo has a _"no brilliant jerks"_ policy, and this extends to
our open source projects.

### Internal

For internal documentation links, please review the [Internal](./docs/INTERNAL.md)
documentation.

### Support

Contact extensions@klaviyo.com

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- BEGIN RELEASE NOTES -->
#### [Unreleased]

#### [5.0.0] - 2026-05-29

##### Added
- WhatsApp consent collection at checkout via a new unified Mobile consent group. Merchants choose to collect consent for SMS, WhatsApp, or both, and a single mobile checkbox at checkout drives per-channel subscriptions in Klaviyo.

##### Changed
- Replaced the SMS consent admin group with a unified Mobile group. Existing SMS settings are migrated to the new paths on upgrade; custom label and disclosure copy is preserved.
- Consent submission at order placement now uses the V3 /api/profile-subscription-bulk-create-jobs/ endpoint instead of the legacy custom webhook.
- Phone numbers collected at checkout are now normalized to E.164 before being sent to Klaviyo.

##### Removed
- Support for PHP versions below 8.1. The plugin now requires PHP 8.1 or later, aligning with Magento 2.4.5+. Merchants on PHP 7.x must upgrade their PHP runtime before installing this release.

#### [4.4.4] - 2026-04-30

##### Changed
- Update Klaviyo V3 API revision to 2026-04-15.

##### Fixed
- Fixed race condition for adding profiles to a list, retries subscription if we attempt to create a profile that already exists.

#### [4.4.3] - 2026-02-17

##### Added
- Adds AddedItemImageUrl to Added To Cart event payload

##### Fixed
- Added fallback image selection for Added To Cart events to fix cases where there is no "small_image" set on the product. This greatly reduces the possibility that "AddedItemImageUrlKey" will be set to null or "no_selection"

#### [4.4.2] - 2025-11-04

##### Changed
- Update Klaviyo V3 API revision to 2025-10-15

##### Added
- Add isKlaviyoEnabled to product/viewed.phtml.

##### Fixed
- Ensure Controller/Checkout/Email.php loads proper classes on frontend.

#### [4.4.1] - 2025-09-15

##### Fixed
- Removes escapeJs call that was preventing Viewed Product events from syncing successfully in 4.4.0

#### [4.4.0] - 2025-08-11

##### Added
- Add 'kl_parent_ids' extension attribute in product requests.

##### Fixed
- null argument to str_replace() caused by getPrice() fallback return of null instead of "0".

#### [4.3.1] - 2025-05-09

##### Fixed
- BUGPORT-8326: Formatted $value field in Viewed Product snippet causes API error in latest extension.

#### [4.3.0] - 2025-04-16

##### Added
- Add 'external_catalog_id' and 'integration_key' to Viewed Product and Added To Cart events.
- Adds 'value' field to Viewed Product events

##### Changed
- Bumps Klaviyo API revision to 2025-04-15

##### Fixed
- Fixed Deprecated use of base64_encode in Observer/SalesQuoteSaveAfter.php
- Fixed profile identification on checkout page
- Fixed edge case attempting to get product images when product is null

#### [4.2.0] - 2024-09-17

##### Added
- Adds StoreId field to Viewed Product events

##### Changed
- Updated the klaviyo onsite javascript to the new url format

##### Fixed
- Removes call to isLoggerEnabled() in Logger __construct to address "Area Code is already set" issue when running consumer-based jobs

#### [4.1.4] - 2024-05-22

##### Changed
- Updated Added to Cart events to show preference to simple product images over configurable product images.
- Added StoreId and SimpleProductId fields to Added to Cart event.

##### Fixed
- Properly encodes emails before search request to Klaviyo
- Updated KlaviyoV3Api to fix the profile properties sent in events to match the format required the V3 API

#### [4.1.3] - 2024-03-29

##### Fixed
- BUGPORT-1750: unassigned $response variable from api call during list subscription

#### [4.1.2] - 2024-01-31

_(Changelog truncated for .md surface. Full history on https://packagento.com/klaviyo/magento2-extension.)_

## Recent Versions

| Version | Released |
|---|---|
| 5.0.0 | 2026-05-29 |
| 4.4.4 | 2026-04-30 |
| 4.4.3 | 2026-02-18 |
| 4.4.2 | 2025-11-05 |
| 4.4.1 | 2025-09-15 |
| 4.4.0 | 2025-09-04 |
| 4.3.1 | 2025-05-12 |
| 4.3.0 | 2025-04-22 |
| 4.2.0 | 2024-09-24 |
| 4.1.4 | 2024-05-23 |

Showing 10 of 72 versions. Full release history on https://packagento.com/klaviyo/magento2-extension.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-curl | * |
| giggsey/libphonenumber-for-php | ^9.0 |
| magento/module-quote | >=101.1.3 |
| php | ^8.1 |

## Quality

Latest release (5.0.0) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | not tested | not tested | – | – |
| 2.4.8 | – | Pass | not tested | – |
| 2.4.9 | – | – | not tested | not tested |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 494 | 494 warnings (ruleset: Magento2) — 92 auto-fixable with phpcbf |
| PHPMD | Warning | 52 | 52 rule violations (UnusedFormalParameter:28, MissingImport:5, CyclomaticComplexity:4, EmptyCatchBlock:3, UnusedLocalVariable:3) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 14 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 3 | valid; 3 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 92 | 92 | – | – |
| 2.4.8 | – | 93 | 93 | – |
| 2.4.9 | – | – | 93 | 93 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 51 | 51 | – | – |
| 2.4.8 | – | 51 | not tested | – |
| 2.4.9 | – | – | 57 | Error |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["klaviyo/magento2-extension"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

klaviyo is a Magento 2 vendor on Packagento. See https://packagento.com/klaviyo.md for their full catalogue.

