Skip to main content
Solved

__KLA_ID display user name on website

  • October 18, 2024
  • 3 replies
  • 73 views

Forum|alt.badge.img+1
  • Contributor IV
  • 9 replies

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? 

 

Best answer by brittany.klaviyo.dev

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.

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Forum|alt.badge.img+1
  • Author
  • Contributor IV
  • 9 replies
  • October 21, 2024

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.


Forum|alt.badge.img+1
  • Author
  • Contributor IV
  • 9 replies
  • October 21, 2024

I did find this

 

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


brittany.klaviyo.dev
Community Manager
Forum|alt.badge.img+1

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.