Solved

Why is sending only the $id when creating an Event not documented?

  • 8 June 2023
  • 6 replies
  • 212 views

Badge

Hello!

 

I’m working on a Klaviyo integration for a client, and I was testing the Events API to try out some structure for the structure (which Klaviyo recommends against) of sending some events anonymously, prior to having an $email for the user. https://developers.klaviyo.com/en/reference/create_event

 

The API says that the Profile must contain an identifier of $email or $phone_number:

 

I tested out just sending the external ID in the `$id` field in the profile part of the request, and found that the API does accept that as an identifier as well, and creates a profile that doesn’t have an email (which is the feature that I was looking for).

 

Is this a known feature of this endpoint? Can this be added to the documentation?

icon

Best answer by Omar 17 June 2023, 01:09

View original

6 replies

Userlevel 4
Badge +7

For what it’s worth, this sounds like a helpful feature with an obvious use case, and the documentation should reflect that a profile’s ID can also be used as an identifier. 

@jballo919 what did your request body look like? 

Something like this?

{
  "data": {
    "type": "event",
    "attributes": {
      "profile": {
        "id": "{klaviyoProfileId}"
      },
      "metric": {
        "name": "{event name}"
      }
    }
  }
}

Cheers,

Kevin.

Badge

 Ah sorry I should have used “External ID” as the keyword in my original post - I found that I can pass just an external identifier in the `$id` field of the `profile` part of the request body, and this will set the external ID on the profile.

 

Example request:

{
  "data": {
    "type": "event",
    "attributes": {
      "profile": {
        "$id": "{externalID}"
      },
      "metric": {
        "name": "{event name}"
      }
    }
  }
}

This will then create a new profile (with some Klaviyo Profile ID that gets set), and put the string I put in `$id` as the external ID of that profile.

 

Example:

 

In this example, I sent `$id` as `”c06b1996-d2fb-45a7-a834-8882a9f2f842”`

 

I also found that if I send this on an event where I send the email of an existing profile, this will reset the External ID on the profile matching that email.

 

It would be great if both of these are documented features of the API, so that I can confirm that I can build our integration with these assumptions in mind.

Badge

@KeviSunshine any update on this topic? Is this a feature of the API that is supposed to exist, and can it be added to the documentation?

Userlevel 4
Badge +7

Hey @jballo919,

I wish I could help you more but I am not affiliated with Klaviyo in any official capacity! I am just a fellow developer that uses Klaviyo a lot and sometimes hangs out on the forums!

Lets ping @David To on this one. He’s the community manager :)

 

My opinion is that this functionality is intentional and will continue to be supported. 

From my experience, Klaviyo doesn’t update their developer documentation very frequently and it’s often lacking options/examples/advanced scenarios.

 

Cheers,

Kevin.

Userlevel 7
Badge +36

Hi @jballo919 and @KeviSunshine!

Thanks for bringing this up! I’m going to check with Engineering to confirm this functionality and adjust the documentation if necessary, and then I’ll update the thread!

 

Best,
- Brian

Userlevel 7
Badge +44

@jballo919 I'm not a developer but I know that Klaviyo does allow you to use your own identifiers instead of email. 

They do advise against using them, or better said to use email as an identifier and if you do want to use id's you're responsible for the identity management.

I suggest to read this part of the documentation about this.

https://developers.klaviyo.com/en/v1-2/docs/custom-integration-faqs#should-i-use-email-or-id-as-my-unique-identifier

 

Does that help?

 

Regards,

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO

Reply