Skip to main content
Contributor I
Apr 17, 2024 10:46 AM UTC
Solved

Accessing Cookie or Identifying Tracked User

I’m working on a custom integration for our app, where we would want to query klaviyo to get a profile ID from the cookie or session somehow. Meaning, what I’m trying to do is be able to retrieve a profile ID from the cookie or something so i can map it back to a call for the full profile etc. 

Is this somehow possible? Can’t seem to find the api docs or guide on how we would be able to identify a klaviyo profile/tracked user on the merchant site while the site is loading/page loaded etc. 

    This topic has been closed for replies.
    saulblumAnswer
    Klaviyo Employee
    Apr 17, 2024 11:47 AM UTC

    The __kla_id cookie is a base64-encoded JSON block. If there’s an identified profile, there will be a property such as:

    "$exchange_id":"bIgfUuOCPJUzy9lKtTkDmnAS8EE6u0FxfWDk07E-sAytXAgIwM3cG9F216V5Gvmn.PGuJQv"

    You can use this value in a filter in Get Profiles in a server-side call:

    https://developers.klaviyo.com/en/reference/get_profiles

     

     

    This would give you the profile ID.

    No PII is exposed in the cookie itself, so you’d have to  make this server-side API call.

    12 replies

    Contributor IV
    Oct 21, 2024 7:46 PM UTC

    will do! 

    Contributor II
    Dec 16, 2024 9:07 PM UTC

    Hey,

     

    Were you able to figure out why you got that "Invalid _kx token" error? I extracted it using the same method you did, and in most cases it works, but sometimes I get this error still.