Solved

Can you use _learnq to retrieve custom properties?

  • 20 July 2022
  • 2 replies
  • 118 views

Badge +2

Hi Everyone,

 

We are using Klaviyo’s client-side _leanq JS library to push custom properties for an ‘identified’ user (via _learnq.push), but we can’t seem to figure out if there’s a way to retrieve custom properties using the _learnq library.  Does anyone know if this is possible?  I know we can do this via a server-side call (such as the Profiles API) with our private token but that’s not an option at this point and need to use some kind of a client-side JS call like _learnq that doesn't require our private_api key.  

 

Any help is greatly appreciated 🙏

icon

Best answer by Brian.Cameron 20 July 2022, 23:00

View original

2 replies

Badge +1

Hey there, 

Brian here from the support engineering team, just wanted to provide some insight on this issue for visibility.

Unfortunately, there aren’t any accessible methods that could be used to retrieve custom properties from profiles through our Klaviyo JS.  These calls are generally used to POST information to the user profile and retrieval from the front end would create somewhat of a security risk.  Typically as it relates to customer information, most of our calls would require a request containing your private api key in which you’d generally have to pass through on your backend or through middleware.


I know you mentioned that our API isn’t really a feasible option for you, but we'd really only be able to make these calls via our API either from your backend or another REST api to serve up these calls to your frontend.   

We may potentially have some alternatives in the pipeline with our v3 API however nothing is set in stone yet for the general release.  In the interim, if you do reconsider using our API, your best bet would be our get profile endpoint:
https://developers.klaviyo.com/en/reference/get-profile

 

Thanks for your patience and understanding; I’ll be sure to pass this along as a potential blocker for users looking to make use of custom properties client side.

Badge +2

Thanks for the reply Brian.  Unfortunately we have a Shopify store and as I’m sure you know, making a server side call is non trivial and involves building a private app as liquid has no mechanism to make a server side call by default.  
 

Totally understand the concern for security risks but maybe a compromise on the client side is to restrict it to the identified user and to also sandbox profile access to just custom properties which would be made available if we as users enable a toggle to allow client side custom properties access in our settings. That way you guys are covered because access is off by default, and we as users need to explicitly enable it with an understanding that we shouldn’t use custom properties with information that we wouldn’t want publically available.  In our case for instance, we would be storing timestamps and whatnot so there’s no worry of data security,  

 

Reply