Skip to main content
Contributor I
April 17, 2024
Solved

Accessing Cookie or Identifying Tracked User

  • April 17, 2024
  • 12 replies
  • 1259 views

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.
    Best answer by saulblum

    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
    October 21, 2024

    will do! 

    Contributor II
    December 16, 2024

    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.