---
title: "Integrate a content-based platform"
description: "Learn how to sync a content-marketing platform with Klaviyo using open source APIs and custom options."
url: "https://developers.klaviyo.com/en/docs/guide_to_integrating_a_content_based_platform"
category: "Integrate with Klaviyo"
lastUpdated: "2026-04-17"
related: ["https://developers.klaviyo.com/en/docs/llms.txt"]
---

# Integrate a content-based platform

> This is the Markdown version of https://developers.klaviyo.com/en/docs/guide_to_integrating_a_content_based_platform

Learn how to sync a content-marketing platform with Klaviyo using open source APIs and custom options.

If you’re using an ecommerce platform not currently supported by one of Klaviyo’s [pre-built integrations](https://help.klaviyo.com/hc/en-us/categories/115000032731-Ecommerce-Integrations) or [partner integrations](https://marketplace.klaviyo.com/en-us), or you’ve built your own custom solution, you can integrate with Klaviyo using our APIs, which enable, for example:

- Onsite activity tracking with the [JavaScript API](https://developers.klaviyo.com/en/docs/javascript_api.md).
- Managing lists and segments with the [server-side API](https://developers.klaviyo.com/en/reference.md).
- Creating and managing custom [catalogs](https://developers.klaviyo.com/en/docs/guide_to_syncing_a_custom_catalog_feed_to_klaviyo.md).

## Key integration components

The key components of integrating a content website are:

- **Reader data**  
  Tracking information such as name, email, phone number, or other profile attributes.
- **Email subscribers**  
  Tracking who is subscribed to your newsletter.
- **Website subscribers**  
  Tracking who is subscribed to your website.
- **Website activity**  
  Tracking who is active on your site, what experiences they view, etc.
- **Content catalog**  
  Syncing your catalog of content to Klaviyo.

## About JavaScript and server-side event APIs

This guide focuses on how to sync important metrics, or key customer activities, to Klaviyo. These events can be created in the browser with the [JavaScript API](https://developers.klaviyo.com/en/docs/javascript_api.md) and on the backend with the [server-side API](https://developers.klaviyo.com/en/reference.md).

- Use our JavaScript API for the following:

  - **Active on Site**  
    When someone visits your website
  - **Viewed Article**  
    When someone views an article
  - **Viewed Author**  
    When someone views an author
  - **Viewed Category**  
    When someone views a category
  - **Read Article**  
    When someone finishes reading an article
  - **Followed Article**  
    When someone follows an article
  - **Followed Author**  
    When someone follows an author
  - **Followed Category**  
    When someone follows a category

- Use our server-side Identify API for the following:

  - **Followed Articles**  
    List of names of articles someone follows for updates
  - **Followed Authors**  
    List of names of authors someone follows
  - **Followed Categories**  
    List of names of categories someone follows

- Use our [custom catalog feed](https://developers.klaviyo.com/en/docs/guide_to_syncing_a_custom_catalog_feed_to_klaviyo.md) for the following:

  - **Feed of articles**  
    An XML feed or JSON feed of all articles on the website

> [!WARNING]
> For populating your Klaviyo product catalog, you can use either a custom catalog feed or the [catalog API](https://developers.klaviyo.com/en/reference/get_catalog_items.md). You can only populate products using one option. To shift from a custom catalog feed to the new catalog API you must first disable the existing custom catalog feed before using the API.

Filtering and segmenting on these events will be based on the level of detail in the event data sent to Klaviyo. To understand how data must be structured so that key event details are available for segmentation, check out our articles on <a href="https://help.klaviyo.com/hc/en-us/articles/115005062847-Understand-the-Data-Available-for-Segmentation" target="_blank">segment conditions</a> and [how to structure your data for segment and flow filters](https://developers.klaviyo.com/en/docs/custom_integration_faqs.md).

> [!WARNING]
> The code snippets in this guide use example data. You will need to update the values of the JSON properties in these snippets so that they dynamically pull from the relevant information needed for that property.

Check out our [Custom integration FAQ](https://developers.klaviyo.com/en/docs/custom_integration_faqs.md) for any questions about custom integrations. 

## JavaScript Track API for onsite metrics

### Active on Site tracking snippet

To be able to publish forms directly from Klaviyo to your site, add the following JavaScript snippet so it appears on every page on your website (the end of the footer is often a good place to add it). Replace `PUBLIC_API_KEY` with your Klaviyo account's six character [public API key](https://help.klaviyo.com/hc/en-us/articles/115005062267-How-to-Manage-Your-Account-s-API-Keys):

```javascript
<script type="application/javascript" async
src="https://static.klaviyo.com/onsite/js/PUBLIC_API_KEY/klaviyo.js"></script>
```

Once you’ve added the snippet above, an Active on Site metric will trigger for any person who is cookied. A browser can be cookied in any of the ways listed in our <a href="https://help.klaviyo.com/hc/en-us/articles/115005076767-Klaviyo-Web-Tracking#who-klaviyo-tracks1" target="_blank">article on Klaviyo onsite tracking</a>.

### Initialize the `klaviyo` object

Ensure that you have [initialized the klaviyo object](https://developers.klaviyo.com/en/docs/introduction_to_the_klaviyo_object.md) on your page before executing any of the following code snippets.

### Viewed event tracking snippet

If you'd like to set up a <a href="https://help.klaviyo.com/hc/en-us/articles/115002775252-Create-a-Browse-Abandonment-Flow" target="_blank">read/browse abandonment flow</a> or build segments based on article browsing data, you'll need to add JavaScript event tracking for a Viewed metric. All Viewed metrics are tied to user profiles. Users must already be cookied by Klaviyo in order for these metrics to track properly. After you configure tracking for these Viewed events on your site, this data will begin populating in your Klaviyo account as known visitors browse your pages.

> [!NOTE]
> Replace `item.___` in the below code snippets with whatever item object your platform uses for product properties.

#### Viewed Article

To track a viewed article, add the following snippet to your article template:

```javascript
<script type="text/javascript">
   var item = {
  "Title": item.Title,
  "ArticleID": item.ArticleID,
  "Author": item.Author,
  "PublicationDate": item.PublishDate,
  "Categories": item.Categories,
  "ImageURL": item.ImageURL,
  "URL": item.URL
 };
 klaviyo.track("Viewed Article", item);
</script>
```

You can also track a recently viewed item on a person’s profile under a “Recently Viewed Items” section by adding the following snippet directly below the Viewed Article snippet above. 

Calling the Klaviyo object's `trackViewedItem` function below will populate a product feed of recently viewed products that can be included in emails. For more information on how to use the “Recently Viewed Items” feature in a template, check out our article on [inserting recently viewed items into an email](https://help.klaviyo.com/hc/en-us/articles/360019921772-How-to-Insert-Recently-Viewed-Items-into-an-Email).

The following snippet can be added directly below the _Viewed Product_ snippet:

```javascript
<script type="text/javascript">
 klaviyo.trackViewedItem({
  "Title": item.Title,
  "Categories": item.Categories,
  "ImageUrl": item.ImageURL,
  "Url": item.URL,
  "Metadata": {
   "Author": item.Author,
   "PublicationDate": item.PublicationDate
  }
 });
</script>
```

#### Viewed Author

To track a viewed author, which can be used to alert readers about articles by that author, add the following snippet to your author template:

```javascript
<script type="text/javascript">
 klaviyo.track("Viewed Author", {
  "Name": item.Name,
  "AuthorID":item.AuthorID,
  "Categories": item.Categories,
  "ImageURL": item.ImageURL,
  "Bio": item.Bio,
  "URL": item.URL
 });
</script>
```

#### Viewed Category

To track a viewed category, which can be used to alert readers about articles in that category, add the following snippet to your category template:

```javascript
<script type="text/javascript">
 klaviyo.track("Viewed Category", {
  "Title": item.Title,
  "CategoryID": item.CategoryID,
  "ImageURL": item.ImageURL,
  "URL": item.URL
 });
</script>
```

#### Read Article

In order to build segments based on a person's past reading interests, or to filter people out of a <a href="https://help.klaviyo.com/hc/en-us/articles/115002775252-Create-a-Browse-Abandonment-Flow" target="_blank">read abandonment flow</a>, you'll need to add JavaScript event tracking for a Read Article metric. Read Article can be implemented in a few different ways.

For example, if you have a method of estimating the amount of time it takes a person to read an article on your site, you can set the event to track after a delay in that estimated amount of time (represented by `readingTime` below):

```javascript
<script type="text/javascript">
 var readingTime = 12; // Estimated amount of minutes to read article
 setTimeout(function() {
  klaviyo.track("Read Article", {
   "Title": item.Title,
   "ArticleID": item.ArticleID,
   "Author": item.Author,
   "PublicationDate": item.PublishDate,
   "Categories": item.Categories,
   "ImageURL": item.ImageURL,
   "URL": item.URL
  });
 }, (readingTime * 60 * 1000));
</script>
```

Alternatively, you can track when someone reaches the bottom of an article. To trigger the event after someone reaches a specific part of the page, you can use something like the following code snippet. This snippet will trigger the event at a specific pixel offset from the bottom of the page (`bottomOffset`):

```javascript
<script type="text/javascript">
 var bottomOffset = 2423; // Amount of pixels the end of the article is from the bottom of the page.
 trackReadArticle = function(e) {
  if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight - bottomOffset) {
   window.removeEventListener("scroll", trackReadArticle, true); // Stop the onscroll function from triggering more than once
   klaviyo.track("Read Article", {
   "Title": item.Title,
   "ArticleID": item.ArticleID,
   "Author": item.Author,
   "PublicationDate": item.PublishDate,
   "Categories": item.Categories,
   "ImageURL": item.ImageURL,
   "URL": item.URL
   });
  }
 };
 window.addEventListener("scroll", trackReadArticle, true); 
</script>
```

### “Followed” Events

If readers are able to follow certain articles, authors, or categories on your site, you can track an event for the follow to:

- Trigger any follow-up flows 
- Target your messages around that action

Along with these events, tracking profile properties representing a list of who or what a reader currently follows allows you to target them using filters and segments based on these follows. 

Followed events use both JavaScript API and server-side event API requests. The event can be passed with our JavaScript API when the reader clicks the follow button. The profile property should be synced via a server-side request in order to keep it up to date. 

#### Followed Article

You can track a _Followed Article_ event when a person clicks the "follow" button for an article by adapting the following snippet and adding it to your article template. In this example, the follow button has an id of followArticleButton, which you should replace with the ID of your own button. 

```javascript
<script type="text/javascript">
document.getElementById("followArticleButton").addEventListener("click",function(e){
  klaviyo.track("Followed Article", {
   "Title": item.Title,
   "ArticleID": item.ArticleID,
   "Author": item.Author,
   "PublicationDate": item.PublishDate,
   "Categories": item.Categories,
   "ImageURL": item.ImageURL,
   "URL": item.URL
  });
 });
</script>
```

In addition to the event above, you can send a server-side Identify API request containing all of the articles a person currently follows. The payload should look something like this:

```json
{
 "token": "PUBLIC_API_KEY",
 "properties": {
   "email": "john.smith@test.com",
   "FollowedArticles": ["The Ultimate Guide to (Last Minute) Holiday Marketing","4 Steps for a Successful Holiday Season with Klaviyo"],
   "FollowedArticleIDs": ["holiday-marketing-101","4-step-holiday-kla"]
 }
}
```

#### Followed Author

You can track a _Followed Author_ event when a person clicks the "follow" button for an author by adapting the following snippet and adding it to your author template. This example’s button has an id of followAuthorButton.

```javascript
<script type="text/javascript">
document.getElementById("followAuthorButton").addEventListener("click",function(e){
  klaviyo.track("Followed Author", {
   "Name": item.Name,
   "AuthorID": item.AuthorID,
   "Categories": item.Categoreis,
   "ImageURL": item.ImageURL,
   "Bio": item.Bio,
   "URL": item.URL
  });
 });
</script>
```

In addition to the event, send a server-side API request containing all of the authors a person currently follows. The payload should look something like this:

```json
 "properties": {
   "email": "john.smith@test.com",
   "FollowedAuthors": ["Mike Green","Dan Cohen"],
   "FollowedAuthorIDs": ["mg-01","dc-02"]
 }
```

#### Followed Category

You can track a _Followed Category_ event when a person clicks the "follow" button for a category by adapting the following snippet and adding it to your category template. This example’s button has an id of followCategoryButton.

```javascript
<script type="text/javascript">
document.getElementById("followCategoryButton").addEventListener("click",function(e){
  klaviyo.track("Followed Category", {
   "Title": item.Title,
   "CategoryID": item.CategoryID,
   "ImageURL": item.ImageURL,
   "URL": item.URL
  });
 });
</script>
```

In addition to the event, you can send a server-side Identify API request containing all of the categories a person currently follows. The payload should look something like this:

```json
 "properties": {
   "email": "john.smith@test.com",
   "FollowedCategories": ["Email Marketing","Black Friday"],
   "FollowedCategoryIDs": ["email-marketing","blk-fri"]
 }
```

## Catalog feed integration

Integrating your catalog will allow you to utilize <a href="https://help.klaviyo.com/hc/en-us/articles/115000219092-Insert-a-Product-Block" target="_blank">product blocks</a> in emails. To set up a custom catalog integration, please follow Klaviyo’s [custom catalog sync integration process](https://developers.klaviyo.com/en/docs/guide_to_syncing_a_custom_catalog_feed_to_klaviyo.md). 

Note that Klaviyo’s catalog feed examples include some product specific fields like "price". If your articles do not require a purchase, you can leave this field out. "categories" is also an optional field, but we highly recommend including these as they enable you to create product feeds that include or exclude certain categories.

## Other considerations

If people can subscribe to paid content on your website, you can follow our article [Integrate a subscription ecommerce platform](https://developers.klaviyo.com/en/docs/guide_to_integrating_a_subscription_ecommerce_platform.md). The guide outlines how to sync customer data, email subscribers, website activity, order activity, and subscriptions. 

## Example flow ideas

### Browse abandonment

**Purpose**: Re-engage browsers who landed on a category page but never looked at an article.

**Trigger**: _Viewed Category_

**Flow Filter**: _Has Viewed Article zero times since starting this flow_

### Read abandonment

**Purpose**: Re-engage browsers who landed on an article page but did not stay long enough to read it.

**Trigger**: _Viewed Article_

**Flow Filter**: _Has Read Article zero times since starting this flow_

## Additional resources

- [Custom integration FAQs](https://developers.klaviyo.com/en/docs/custom_integration_faqs.md)

- <a href="https://community.klaviyo.com/groups/developer-group-64" target="_blank">Developer Group on the Klaviyo Community</a>
