Skip to main content

I am trying to display Klaviyo profile name based off of __kla_id cookies.  I cannot seem to find any information on how to do this on our site.  I have been able to get profiles info if use email address but I want to use __kla_id

Can this be done? 

 

Is this correct method?

 

Step 1: Extract __kla_id Cookie

Use JavaScript to retrieve the __kla_id cookie and decode it to obtain the _kx value.

Step 2: Exchange _kx for Profile ID

Make a POST request to Klaviyo’s /api/v2/people/exchange endpoint with the _kx value to retrieve the profile ID.

Step 3: Get Profile Details

Use the GET /api/profiles endpoint with the profile ID to fetch the profile data, including the first name.

Step 4: Display First Name

Once you get the first name from the API, update the HTML element with the user's name.

Code Workflow (Simplified)

  1. JavaScript: Extract the __kla_id and send it to your server.
  2. PHP (or server-side code): Use Klaviyo API to get the user’s profile data.
  3. Return the first name to JavaScript, which displays it on the page.

This method ensures you're identifying users securely and dynamically displaying their names.


I did find this

 

But still not clear if it possible to get username on a webpage


It looks like this conversation continued to resolution in the thread you linked above, @Zog! Thanks for being a part of our community and helping others with your detailed solution.


Reply