Stape
Search
Contact salesTry for free

How to improve Klaviyo event tracking: a guide to better data collection

Dan Murov

Dan Murov

Author
Published
Nov 20, 2025

Accurate data collection is essential for building effective marketing strategies. Klaviyo can unify customer identifiers, stitch fragmented events together, and build a complete customer profile. When implemented correctly, Klaviyo's server-side tracking allows brands to collect cleaner data, match users across devices and sessions, and improve the accuracy of automations.

In this guide, we will explore how to get precise data from Klaviyo, enabling you to harness the full capabilities of Klaviyo by effectively 'backfilling' would-be anonymous events.

Before we dive into how to, let’s briefly see what we’re working with.

What is Klaviyo identity resolution?

Identity resolution refers to the process of maintaining a unified customer record, regardless of the various identifiers (e.g. email, phone number, etc.) used across different touchpoints or devices. As customers interact with your brand across different channels, Klaviyo checks for opportunities to merge these engagements under a single customer profile.

This is based on a process called identifier precedence, where Klaviyo uses existing data to determine if these omni-channel engagements can be consolidated under a single, stronger identifier. Klaviyo ranks these identifiers as:

  1. Profile ID - the primary identifier Klaviyo assigns to each profile. It's almost never used explicitly.
  2. External ID – usually, this is an actual logged-in customer ID, persistent on your backend. External ID can be used as a primary identifier of the profile, typically in place of the email address.
  3. Email - the email address associated with a profile. This is your most common identifier.
  4. Phone number - the phone number associated with a profile.
  5. Anonymous ID - if Klaviyo cannot associate a user with an email address, an anonymous ID will represent it.

Guide on using Anonymous ID in your Klaviyo server-side GTM setup

Today we are looking at Anonymous ID, for two main reasons:

  1. Effectively, we will be tracking anonymous events. So using Anonymous ID fits perfectly for the purpose.
  2. It's the lowest one in the identifiers hierarchy, therefore our efforts will not interfere with identity resolution based on other, more prevalent IDs and common scenarios.

As explained above, Klaviyo requires at least one identifier to create a profile entity for tracking events. Our goal is to add an anonymous ID to our tracking tags. This includes tags where an email is always expected (e.g., Purchase) as well as those where an email is only occasionally expected (e.g., Active on Site, View Item).

We need something persistent that lasts at least for a single session, ideally even longer. You can use cookies that your tracking stack already generates, like FPID from GA4, _fbp from Facebook, or another persistent cookie, storage, or variable. For the purposes of this guide we will use Stape User ID as our anonymous identifier. We will also assume you have a basic Klaviyo setup, as described in our setup guide.

How to use Anonymous ID

1. Make sure the User ID power-up is turned on (alternatively, you can replace it with any other persistent id you have access to and skip this step in such case).

Stape User ID power-up
Stape User ID power-up

2. Create a Request Header variable in your server GTM to pick up User ID value.

Request Header variable configuration
Request Header variable configuration

3. Assign your variable as Anonymous ID in Klaviyo tags.

Anonymous ID in "Added to Cart" event
Anonymous ID in "Added to Cart" event
Anonymous ID in "Placed Order" event
Anonymous ID in "Placed Order" event
Both our anonymous events, and events carrying email will now share Anonymous ID, making it possible to resolve them to a single profile.

4. Test & publish!

Now let's check this in action:

  • Added to Cart event fires w/o email, i.e., anonymously, but the request actually gets delivered (see 202 status) because it carries one of the supported identifiers.
"Added to Cart" event details
"Added to Cart" event details
  • As we passed an Anonymous ID, a blank profile with our Added to Cart gets created in Klaviyo.
"Added to Cart" event created in Klaviyo
"Added to Cart" event created in Klaviyo
  • We then identify ourselves on the site by making a Purchase (other cases like customer login, of course, apply as well).
"Placed Order" event details
"Placed Order" event details
  • Our profile is no longer anonymous because it now includes the user's email. Events that we triggered anonymously (e.g., Added to Cart) are still part of the history and can be used in your automations.
Profile containing the user's email with anonymous events recorded in Klaviyo
Profile containing the user's email with anonymous events recorded in Klaviyo

➡️ Note: had we identified ourselves with an email that already had a record in Klaviyo - a profile merge would occur automatically combining our historical data with the anonymous session, as can be seen below.

Profile merge in Klaviyo
Profile merge in Klaviyo

Results: 37% increase in Added-to-Cart events

By using the capabilities of Klaviyo API combined with tools from Stape, we can now collect anonymous events to our Klaviyo in a way that they will ultimately resolve to actual emails, once customers identify themselves.

In our trial run with a partner shop over a week native Klaviyo tracking delivered:

  • 421 Added to Cart events, while the method above delivered 577 cart additions, only counting the non-anonymous profiles (so, those that resolved to an email in the end) - that is a 37% increase w/o any significant effort.

Want to start on the server side?Register now!

author

Dan Murov

Author

Dan, an expert in server-side tracking and GTM, helps businesses optimize tracking and data accuracy. A MeasureCamp speaker, he simplifies advanced tracking for marketers, developers, and analysts.

Comments

Try Stape for all things server-side