> For the complete documentation index, see [llms.txt](https://docs.fieldsraven.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fieldsraven.app/klaviyo.md).

# Klaviyo

#### To sync Shopify metafields with Klaviyo you need to create a "Private API Key" in Klaviyo

<div><figure><img src="/files/fXoKekURfI6A5VZeffzr" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ekS03GNvMLQmDKk3F0QP" alt=""><figcaption></figcaption></figure> <figure><img src="/files/CElWuEz7Cx7KrLeoidPM" alt=""><figcaption></figcaption></figure></div>

### Setup Klaviyo sync in FieldsRaven

{% hint style="warning" %}
Klaviyo sync only works with the customer resource
{% endhint %}

When creating a new Raven toggle the "Sync with Klaviyo" button and add the Klaviyo's API key.

Demo -> <https://monosnap.com/file/DB1bRi7qixXvlVdVws37f4grQdJo1J>

<figure><img src="/files/kyPIRvpzk1PMaftCEwc8" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
It takes about 10 seconds after the Shopify metafiled is created/updated for the KlaviyoSync job to kick in
{% endhint %}

#### Sync Shopify metafield into Klaviyo customer profile

When you sync a metafield into Klaviyo's customer profiles, property name in Klaviyo will be the metafield's key in Shopify. For example if you're syncing this metafield `customer.metafields.social_media_profiles.facebook` then property name in Klaviyo will be `facebook`&#x20;

<figure><img src="/files/s1LFKHs3ylkStLGvvlPU" alt="Klaviyo customer property name screenshot"><figcaption><p>Klaviyo customer property name example</p></figcaption></figure>

#### Sync Shopify JSON metafield into Klaviyo customer profile

When you sync a JSON type metafield, each property of the JSON object gets converted into a customer property in Klaviyo, this object:

```json
{
  "facebook": "Share on Facebook",
  "twitter": "Tweet on Twitter",
  "pinterest": "Pin on Pinterest",
  "timestamp": `${Date.now()}`
}
```

Or this:

```json
{
  "Serial Number": "000123456789",
  "Country of Residence": "Canada",
  "Where did you purchase your meter?": "Amazon"
}
```

Becomes as follows in Klaviyo:

<figure><img src="/files/r9VCXbBDrtvNbw1V01ZL" alt="Sync Shopify JSON metafield into Klaviyo customer profile"><figcaption><p>Sync Shopify JSON metafield into Klaviyo customer profile</p></figcaption></figure>

<figure><img src="/files/F3KEfPzkSlPyMIWHCKwp" alt=""><figcaption></figcaption></figure>

#### Nested JSON metafield

TBC

```json
{
  "name": "Ram",
  "age": 27,
  "vehicles": {
    "car": "limousine",
    "bike": "ktm-duke",
    "plane": "lufthansa"
  }
}
```

<figure><img src="/files/WjdI4RhMlBO6StaIxxRj" alt="Syncing nested JSON metafield with Klaviyo"><figcaption><p>Syncing nested JSON metafield with Klaviyo</p></figcaption></figure>

```json
{
  "name": "Ram",
  "age": 27,
  "vehicles": ["limousine", "ktm-duke", "lufthansa"]
}
```

<figure><img src="/files/xQ9mgNACacwf2ofbUK4K" alt="Syncing nested JSON with nested array with Klaviyo"><figcaption><p>Syncing nested JSON with nested array with Klaviyo</p></figcaption></figure>

#### Array of JSON metafields

```json
[
  {
    "name": "Martha",
    "age": 37,
    "other": {
      "Favorite color": "Blue",
      "Vehicle": "2009 SSC Aero",
      "GUID": "890d954a-4a57-4659-b10d-e16427358b99"
    }
  },
  {
    "name": "Bonnie",
    "age": 29,
    "other": {
      "Favorite color": "Orange",
      "Vehicle": "1998 Daewoo Prince",
      "GUID": "b902c384-2e1c-44de-a8d3-59b92a2afddd"
    }
  },
  {
    "name": "Bridgette",
    "age": 41,
    "other": {
      "Favorite color": "Purple",
      "Vehicle": "1997 Suzuki Cappuccino",
      "GUID": "aad8ceb9-566e-4b9f-a64a-23af8671eb96"
    }
  }
]
```

<figure><img src="/files/J3md81kEk5F4cWiWgnsi" alt="Syncing an array of objects with Klaviyo"><figcaption><p>Syncing an array of objects with Klaviyo</p></figcaption></figure>
