Skip to main content
Solved

Identify Profile API (check if profile exists with email)

  • September 28, 2021
  • 3 replies
  • 1312 views

Forum|alt.badge.img+2

Hi all,

I need to check if a profile exists on my custom form submission. I already have the custom form submitting to Klaviyo through an API call. What I’d like to do is add another call before this, and check if the email exists already.

 

I’m attempting to use the example shown here: https://apidocs.klaviyo.com/reference/track-identify#identify-get

 

When I run this code, it returns a 1 every time, whether the email / profile exists or not.

Is there a way to check if the profile exists through this endpoint?

 

const options = {
  method: 'POST',
  headers: {Accept: 'text/html', 'Content-Type': 'application/x-www-form-urlencoded'},
  body: new URLSearchParams({
    data: '{"token": "PUBLIC_KEY","properties": {"$email":"ben.franklin@klaviyo.com"}}'
  })
};

fetch('https://a.klaviyo.com/api/identify', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

 

Many thanks for any advice.

Best answer by Dov

Hi @bethanyfish,

Thanks for sharing this question with the Klaviyo community.

The only other way is to use the Lists API endpoint to look for the Profile IDs of multiple profiles in a list/segment: https://www.klaviyo.com/docs/api/v2/lists#get-members-all

You can create a segment of everyone in your account with the following segment logic: Properties about someone > email contains > @. 

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+2
  • Author
  • Contributor I
  • 2 replies
  • September 28, 2021

I should mention I’m also open to other means of doing this. I’m just hoping to avoid having to create a solution with a private API key.

Here’s the code I’m using to add the user to our list:
 

const settings = {
      "async": true,
      "crossDomain": true,
      "url": "https://manage.kmail-lists.com/ajax/subscriptions/subscribe",
      "method": "POST",
      "headers": {
        "content-type": "application/x-www-form-urlencoded",
        "cache-control": "no-cache"
      },
      "data": {
        "g": listID, // list ID is variable
        "email": emailInput // email from input
      }
    }

    $.ajax(settings).done(function (response) {
      // form success stuff
    });

 

This works without problem. 

GOAL: Add an additional check before running this to see if email already exists.


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • September 28, 2021

As a final follow up… if you read this & think this isn’t possible with a public API key, please let me know. I can dig into doing this with GraphQL, but hoping for a quicker solve.


Dov
Forum|alt.badge.img+61
  • Klaviyo Alum
  • 1493 replies
  • Answer
  • September 30, 2021

Hi @bethanyfish,

Thanks for sharing this question with the Klaviyo community.

The only other way is to use the Lists API endpoint to look for the Profile IDs of multiple profiles in a list/segment: https://www.klaviyo.com/docs/api/v2/lists#get-members-all

You can create a segment of everyone in your account with the following segment logic: Properties about someone > email contains > @. 


Reply