Klaviyo Server Side setup in Google Tag Manager

Klaviyo Server Side Tracking

Klaviyo ‘s integration with Google Tag Manager (GTM) via Server Side Tracking is a step forward in making your email marketing strategies more efficient. By using this method, you improve the precision of your data analysis, leading to more targeted and effective marketing efforts. Before you begin, it’s important to make sure your GA4 configuration and events are set up correctly.

Note: Server-side integration in GTM only works if you know a user’s email. This information is needed to associate users on your site with users in the Klaviyo database and add the required events and parameters.

What you must have configured before you begin:

  • Google Analytics 4 configured in the server container
  • Google Analytics 4 events created

What is Klaviyo?

Klaviyo is an email marketing platform that focuses on automating communication processes with customers via email. It provides opportunities for segmentation, personalization and analytics, allowing companies to more effectively address the needs and preferences of their target audience. Klaviyo integrates with a wide range of e-commerce platforms and other tools, streamlining the collection and use of customer data for marketing purposes.

example-claviyo-dashboard

Types of Events You Can Measure With Klaviyo

Within the Klaviyo and Google Tag Manager server-side setup, there are three primary types of events you can measure to capture users’ interactions with your website. Here is an overview:

  1. Active on Site:
    • This Event Type is designed to keep track of when users are active on your site. It can be used to analyze how often and how long visitors view your website, which helps understand their engagement level.
  2. Events:
    • It records specific actions a user performs, such as adding an item to the cart or completing a purchase. This type of event tracking is crucial for understanding the path that leads to conversions and for optimizing the customer journey.
  3. Add to List:
    • This event is used to add users to specific Klaviyo lists, for example, a list of recent buyers. It is useful for segmenting your contacts and sending personalized communications based on the actions they took on your website.

Note: Klaviyo you only need to set up server side . This is because Klaviyo does not currently support deduplication

Set Active on site type

The ‘Active on Site’ type in Klaviyo allows us to monitor users’ activity on the website and collect essential data about their interactions with the site.

Step 1: Create New Klaviyo Tag (Server Container).

Create a new tag within Google Tag Manager by navigating to Tags and click New to create a new tag. Then give the tag a name such as Klaviyo – active on site.

create-new-tag-google-tag-manager Google Tag Manager

Step 2: Tag Configuration (Server Container).

At the tag configuration select Discover more tag types in the Community Template Gallery. Then search for the Klaviyo template and add Import this template.

import-claviyo-template-gtm

Step 3: Klaviyo Tag Setup with Private API Key (Server Container)

The next step is to set up the Active on Site type where you enter your Klaviyo Private API Key. You’ll find this key in your Klaviyo dashboard under Settings and then API Keys, where you can generate and copy the key for use in Google Tag Manager.

create-prive-api-key-klaviyo

Step 4: Email Variable (Server Container).

Add an email variable to the Klaviyo tag configuration. If you haven’t created this variable before, now is the time to do so. Below is an example of an e-mail variable. Note this may vary by data layer. Don’t know what data layer you have? Then check out our explanation of the Data Layer.

create-email-variable-gtm

Step 5: Klaviyo User ID (Server Container).

You add your Klaviyo User ID to the tag. This ID can be found in the Klaviyo dashboard under API Keys, where you will see your Public API Key.

public-api-key-klaviyo

Be sure to also enable the Use Optimistic Scenario and Store email in cookies options to ensure that email addresses are saved and used for optimistic approaches in data analysis. Below is an example of what the configuration might then look like:

klaviyo-active-on-site-configuration

Step 6: Trigger All Pages (Server Container).

As a final step, add the All Pages trigger to activate the Klaviyo tag on each page. With these settings, your Klaviyo tags are ready to track site-wide user activity.

klaviyo-active-on-site-tag-all-pages

Creating Klaviyo tags based on events

Next, we are going to configure a Klaviyo tag based on specific events.

Step 1: Create New Tag Go inside Google Tag Manager (Server Container).

Go to the Tags section and click New to start a new tag. For example, name this tag as Klaviyo Events.

create-new-tag-google-tag-manager Google Tag Manager

Step 2: Klaviyo Events Tag Setup (Server Container).

When setting up the tag, choose the Event type. Enter your Klaviyo Private API Key here, along with the email variable and Klaviyo User ID you set up earlier. For Event Name, use the built-in variable event name. Again, activate the Use Optimistic Scenario and Store email in cookies options.

klaviyo-event-tag-configuration

Step 3: Add Custom Properties (Server Container).

You now have the ability to add custom properties to your event tag. These can range from general information to specific location data, depending on what you need for your data analysis.

add-custom-properties-claviyo-tag

Importantly, the address is a string of street name. You cannot send arrays with it, because of this Klaviyo event tag will give an error.

Step 4: Add Triggers (Server Container).

Then determine which events you want to measure, such as add_to_cart and purchase, and add them to your tag as triggers. If you are not yet familiar with creating these triggers, please refer to our tutorial blog on setting up events in Google Tag Manager.

add-triggers-to-klaviyo-event-tag

By following these steps, Klaviyo allows you to capture detailed information about user behavior, which is invaluable for refining your marketing campaigns and increasing your conversion rates.

Add to list type

In addition to Active on Site and event-based tags, Klaviyo also provides functionality to add users to specific lists, such as a list for all buyers. Here’s how to set up the Add to List tag in Google Tag Manager.

Step 1: Create New Tag (Server Container).

Start creating a new tag by going to Tags in Google Tag Manager and clicking New. For example, name this tag Klaviyo – Add to List.

create-new-tag-google-tag-manager (2)

Step 2: Klaviyo Add to List Tag Setup (Server Container)

Select Add to List as the tag type. Next, enter your Klaviyo Private API Key and List ID. To find your List ID, in your Klaviyo account navigate to the Lists & Segments tab, select a specific list and go to the Settings tab. At the top of the page you will find your List ID.

find-list-id-klaviyo

Add the mail variable and check the Use Optimistic Scenario option; the rest of the settings can remain at the default values.

klaviyo-add-to-list-tag-configuration

Step 3: Klaviyo Add to List Trigger Setting (Server Container).

Then add the trigger you want to use for this tag, such as Purchase, because this action indicates when a user makes a purchase and is therefore eligible to be added to the buyers list.

Klaviyo Add to List Trigger purchase

Following these steps will activate Klaviyo’s Add to List functionality, giving you the ability to automatically add buyers to a segmented list for further marketing activities.

Outro – Measuring all Klaviyo events

We have now covered the three main types of events: ‘Active on Site’, ‘Events’ and ‘Add to List’. With these settings in Google Tag Manager, you have a solid foundation for tracking and analyzing a wide range of user interactions within Klaviyo. This allows you to increase the effectiveness of your email marketing campaigns and build a richer customer database for future targeting and segmentation. With this knowledge, you are now ready to take full advantage of all Klaviyo’s capabilities.


About the author

Ate Keurentjes

Ate Keurentjes

Server Side Tracking Specialist at TAGGRS

Ate Keurentjes is a Server Side Tracking specialist at TAGGRS. He has experience with various Google Tag Manager concepts. Keurentjes has been editing and writing about the latest developments and trends in data collection / Server side tracking since 2023.

Ready for the next level?

Start with Server Side Tracking and generate more revenue and conversions in a world without third-party cookies.