Marketing & Advertising8 min read

How to Integrate Klaviyo with Your Headless CMS

Sync product, article, and offer content from your headless CMS into Klaviyo so email and SMS campaigns use the same approved copy, images, and links as your site.

Published April 29, 2026
01Overview

What is Klaviyo?

Klaviyo is a marketing automation platform for email, SMS, push notifications, customer profiles, segmentation, and revenue reporting. Ecommerce, retail, and B2C marketing teams use it to run flows like welcome series, abandoned cart, product drops, back-in-stock alerts, and post-purchase campaigns. Its core strength is connecting customer behavior and profile data to personalized messages across owned channels.


02The case for integration

Why integrate Klaviyo with a headless CMS?

Klaviyo campaigns move fast. A product drop might need a landing page, three emails, two SMS messages, UTM-tagged links, localized copy, and a post-purchase flow, all before Friday at 9 a.m. If your site content and Klaviyo content live in separate places, teams end up copying titles, prices, promo codes, product images, and disclaimers by hand. That creates small mistakes that get expensive, like an expired offer in an SMS, a mismatched product image in an email, or a landing page URL without campaign tracking.


03Architecture

Architecture overview

A typical Sanity and Klaviyo integration starts when an editor publishes content in Sanity Studio, such as a product launch, offer, buying guide, or campaign landing page. A Sanity webhook fires on the publish mutation and sends the document ID, type, and operation to a Sanity Function or your own webhook endpoint. That server-side code verifies the webhook secret, then uses @sanity/client to query the Content Lake with GROQ. The query can pull the fields Klaviyo needs, including joined references like brand, category, localized slug, primary image URL, price, promo code, and publish window.


04Use cases

Common use cases

🛍️

Product drop campaigns

Publish a product in Sanity, then sync title, image, price, URL, and launch time to a Klaviyo catalog item for email and SMS launch flows.

🏷️

Offer and promo code messaging

Send approved offer copy, discount codes, start dates, end dates, and legal text from Sanity into Klaviyo campaign content.

📰

Editorial newsletters

Turn Sanity article metadata, authors, images, and category tags into Klaviyo email content without copying from the website.

📦

Back-in-stock and replenishment flows

Keep Klaviyo product content aligned with the live product page before inventory or purchase events trigger automated messages.


05Implementation

Step-by-step integration

  1. 1

    Set up Klaviyo access

    Create or use a Klaviyo account, then create a private API key in Settings. Add only the scopes your integration needs, such as Catalogs Write for product content, Events Write for flow triggers, and Profiles Read if you need to look up customers. Install packages with npm install @sanity/client klaviyo-api.

  2. 2

    Model the content in Sanity Studio

    Create schemas for the content Klaviyo will use. Common fields include title, slug, shortDescription, heroImage, price, brand, category, promoCode, startsAt, endsAt, audienceTags, locale, and klaviyoCatalogId. Keep marketing copy in plain text or Portable Text fields that you intentionally serialize for email.

  3. 3

    Create the publish trigger

    Add a Sanity webhook that fires on publish for the document types you want to sync, such as product, offer, article, or campaign. Use a GROQ-powered filter so test documents, drafts, and unrelated content don't call Klaviyo.

  4. 4

    Add server-side sync logic

    Handle the webhook in a Sanity Function, Next.js route, or small middleware service. Verify the webhook secret, fetch the full document from the Content Lake with GROQ, map it to Klaviyo's API format, and call Klaviyo with your private API key from the server only.

  5. 5

    Connect to Klaviyo's API

    Use Klaviyo's Catalogs API for product or merchandised content, and use the Events API when a published item should trigger or feed a flow. Include Klaviyo's revision header, handle 4xx validation errors, and log the Sanity document ID with each Klaviyo response.

  6. 6

    Test the customer experience

    Publish a test document, confirm the catalog item or event appears in Klaviyo, add it to a campaign or flow, and send test emails and SMS messages. Check image dimensions, URL tracking, personalization fallbacks, consent rules, and what happens when content is unpublished.



07Why Sanity

How Sanity + Klaviyo works

Build your Klaviyo integration on Sanity

Sanity gives you the structured content foundation, real-time event system, and flexible APIs to connect approved product, offer, and editorial content with Klaviyo.

Start building free →

08Comparison

CMS approaches to Klaviyo

CapabilityTraditional CMSSanity
Product and offer data for campaignsContent often lives inside pages, so teams copy product names, images, URLs, and disclaimers into Klaviyo by hand.Content is modeled as typed JSON in the Content Lake, with fields Klaviyo can consume directly.
Sync timing after publishTeams often export content on a schedule or wait for someone to update Klaviyo manually.GROQ-powered webhooks and Functions can trigger only on the publish events that matter, then call Klaviyo from server-side code.
Field-level controlThe integration may receive rendered HTML or page-level data, which creates cleanup work before sending to Klaviyo.GROQ can fetch exact fields and references, such as product, brand, category, image URL, and localized slug, in one query.
Editorial workflow for marketing campaignsApproval usually happens around web pages, not reusable campaign fields for email, SMS, and ads.Sanity Studio supports custom editorial workflows, Content Releases, scheduled publishing, Comments, and Tasks for campaign-ready content.
Multi-channel reuseWebsite content and Klaviyo campaign content often diverge after the first copy/paste.One structured back end can power web, mobile, Klaviyo, and AI agents through APIs, Functions, and Agent Context.

09Next steps

Keep building

Explore related integrations to complete your content stack.

Ready to try Sanity?

See how Sanity's Content Operating System powers integrations with Klaviyo and 200+ other tools.