How to get email from API?

  • 27 September 2021
  • 5 replies


Hi all, 

We are trying to have a popup prepopulate with the customers email if they’ve already been cookied by Klaviyo. We are trying to do this either via decoding the b64 klaviyo cookie, or from `_learnq.identify()` however neither output the customers email. Were there changes to the information contained in the cookie directly, or via this method?

When we do: `_learnq.identify()` the output is 

{$source: 'Sign up - Red'}


And when we decode `document.cookie.__kla_id` we get:

{"$source":"Sign up - Red","$exchange_id":"ypr3nGSJO059co*****"}


CCing this thread here as it looks like someone had a similar issue - however I’ve followed the feedback and was unable to get this to work:




Best answer by alex.hong 23 November 2021, 19:53

View original

5 replies



Looking at this, it seems that _learnq.identify().$email used to be included, but due to privacy changes, that will no longer work. Is there an endpoint that can be hit the fetch the email from an exchange id?

Userlevel 5
Badge +30

Hi @Steven Petteruti,

Thanks for posting to the Community with your question!

After speaking with one of our success engineers, I have some information to report that you might find helpful. We changed our JS library to use what's called an "exchange token" which is just an encoded version of somebody's email address that only Klaviyo can decode. We don't save any PII into the cookie anymore, so to my knowledge we can't surface email address in a form anymore. You would need to collect the email addresses from anywhere a customer can input an email address, and save that value to their own cookie or to local storage to use later on rather than using the Klaviyo cookie.

Would love to hear from other community members if they have tried something similar to speak on this as well.


Hope this helped!



Hi @alex.hong ,

Thanks for looking into this for me! 
I had suspected that’s what happened and that there’d be no way to fetch the customers email address from just their exchange token. Perhaps Klaviyo could build an endpoint that lets the merchant decode those exchange tokens, that takes a private api token? That way the PII is secured in the browser - there’s no way to decode the token without an api key. 

For the time being, it looks like we’ll have to implement this with the Shopify customer email, which is less than ideal, as a much smaller percentage of people will be logged into the store vs cookied by Klaviyo. Curious if anyone else has found a workaround here.

Userlevel 5
Badge +30

No problem @Steven Petteruti!

That’s a great suggestion and I’ll gladly forward those thoughts to the right team so that they could have it mapped out for a possible feature for our product. Would love to also see if other community members can shed light on a similar topic. 

Userlevel 5
Badge +30

Hey there @Steven Petteruti!

I wanted to provide you with an update regarding this topic. So our engineering team has recently built an endpoint regarding this situation and thought it would be great to share with everyone here!

The API docs related to this can be found here!


Have a great day!