Klaviyo Lookup Variable for GTM Server Side

This Google Tag Manager Server-Side variable allows you to retrieve a user profile from Klaviyo using the identifier (_kx). It enriches your server-side data with user information such as email, phone number, and address.

How it works

  1. Identifier Detection: The variable first looks for the _kx query parameter in the page URL.
  2. Fallback: If the URL parameter is not present, it attempts to retrieve the identifier from the stape_klaviyo_kx cookie.
  3. Cache Check: The variable checks the templateDataStorage to see if the user data for this identifier is already cached, preventing unnecessary API calls.
  4. API Request: If no cache is found, it sends a GET request to the Klaviyo Profiles API.
  5. Output: It returns either the user’s email or a full user data object based on your configuration.

Parameters

  • Api Key: Input your Klaviyo Private API Key. This is required to authorize the request.
  • Output: Select the type of data to return:
    • Email: Returns only the user’s email address string.
    • All user_data: Returns a JSON object containing the user profile.

Returned Data Structure

If All user_data is selected, the variable returns an object containing the following attributes:

{
  "email": "user@example.com",
  "phone_number": "+1234567890",
  "address": [
    {
      "first_name": "john",
      "last_name": "doe",
      "street": "123 main st",
      "city": "new york",
      "postal_code": "10001",
      "country": "us"
    }
  ]
}

Open Source

Initial development was done by Lars Friis.

Klaviyo Lookup Variable for GTM Server Side is developed and maintained by Stape Team under the Apache 2.0 license.

GTM Gallery Status

:green_circle: Listed

GitHub

:green_circle: Repository

stape-io/klaviyo-lookup-variable — updated: view commit

  • Removed Logs Settings group and related logging functionality from the template
  • Updated API revision date to 2026-04-15
  • Simplified and optimized helper functions, removing logging-related conditionals
  • Cleaned up dependencies, removing unused logging modules and rearranging imports
  • Removed configuration sections related to logging and header access permissions

GTM Gallery Status

:green_circle: Listed