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.
- Identifier Detection: The variable first looks for the
_kxquery parameter in the page URL. - Fallback: If the URL parameter is not present, it attempts to retrieve the identifier from the
stape_klaviyo_kxcookie. - Cache Check: The variable checks the
templateDataStorageto see if the user data for this identifier is already cached, preventing unnecessary API calls. - API Request: If no cache is found, it sends a GET request to the Klaviyo Profiles API.
- Output: It returns either the user's email or a full user data object based on your configuration.
- 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.
- Logs Settings: Control logging behavior:
- Do not log: No logs are generated.
- Log to console during debug and preview: Logs only when GTM is in debug/preview mode.
- Always log to console: Logs requests and responses regardless of the environment.
If All user_data is selected, the variable returns an object containing the following attributes:
{
"email": "[email protected]",
"phone_number": "+1234567890",
"address": [
{
"first_name": "john",
"last_name": "doe",
"street": "123 main st",
"city": "new york",
"postal_code": "10001",
"country": "us"
}
]
}Initial development was done by Lars Friis.
Klaviyo Lookup Variable for GTM Server Side is developing and maintained by Stape Team under the Apache 2.0 license.