Solved

Using api/track without creating new profiles

  • 21 July 2023
  • 8 replies
  • 205 views

Badge
  • Contributor I
  • 4 replies

We have had integration with Klaviyo for several years now but recently we have found an issue with the `api/events` API.
In your documentation it says that “Klaviyo only tracks events when a user is identified”: https://developers.klaviyo.com/en/docs/javascript_api#track-events-and-actions. I am reading it that only after creation of a user their events will be tracked. However using the '2023-02-22' API and sending POST requests to `https://a.klaviyo.com/api/events` new users are created. Is there a way that we can enhance existing Klaviyo users with events without creating new users?
I have also now checked that even with private key with access only to events and not to profiles I am able to create profiles via events

icon

Best answer by Brian Turcotte 3 August 2023, 20:21

View original

8 replies

Userlevel 7
Badge +36

Hi @ela!
 

In the sentence “Klaviyo only tracks events when a user is identified”, the word ‘identified’ does not necessarily mean that there will be a new profile created in every instance.

 

Klaviyo identifies profiles in these ways:

  • If someone has, at some point, clicked through a Klaviyo email to your website.
  • If someone has, at some point, subscribed/opted-in through a Klaviyo form.
  • If someone has, at some point, logged into your site and you have tracking installed.
    • (Typically via the checkout email field or sign-up form)

 

A new profile is created only after the first identification, and Klaviyo will recognize the profile’s browser going forward, so long as the person doesn’t clear their cookies.

 

Furthermore, Klaviyo will not create duplicate profiles for the same identifier (email address) - so using the track or Create Events endpoints will not create a new profile for a site visitor that already has a profile in Klaviyo.

 

So to summarize, Klaviyo must first create a profile for a site visitor before it can start tracking events for that visitor. Additionally, using the track/events endpoints will only create a new profile if there isn’t already a profile using the same identifier (email). 

 

I hope this helps to clarify, and thanks for using the Community!

- Brian

Badge

Hi Brian.
Unfortunately this does not cover what is happening in my case. I used POSTMAN to send POST requests to `api/events` with gibberish email addresses as identifiers, that never had a profile in my Klaviyo instance and the POST request resulted in a new profile.

 

Badge

I didn’t tag you @Brian Turcotte but I’m still hoping to get an answer to the above

Userlevel 7
Badge +36

Hi @ela!

My apologies for the delay - at this time, this is the intentional behavior of the /events endpoint, as Klaviyo cannot track events without appointing them to a profile. 

 

I will update the thread if anything changes to this functionality in the future!

 

Best,

Brian

Badge

Thanks @Brian Turcotte.
Can you let me know if there is another way of using the API so that events are only added for customers who already exist in Klaviyo?
I see two inconsistencies in your APIs with some of them having high privacy implications:
1. You are able to update profiles using API token which does not have profile update permissions
2. As mentioned above the documentation of your API here: https://developers.klaviyo.com/en/docs/javascript_api#track-events-and-actions does not actually reflect how your APIs work

Userlevel 7
Badge +44

@ela,

I'n not a developer but have helped various devs to created custom integrations.

From what I'm hearing you'd like to have some kind of logic that runs a check if a profile exists i.e. with this https://developers.klaviyo.com/en/reference/get_profile and then if it exists to then update the profile.

Does this help?

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

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

Badge

@Brian Turcotte can you please confirm that this is not a behaviour change from how your v1/v2 APIs work. We have upgraded our customers to the 2023-02-22 API and we got a big spike of complains that the `track` event is creating new customers when this was previously NOT THE CASE with v1/v2 APIs

Userlevel 7
Badge +36

Hi @ela!
 

My apologies, I believe I understand your use case better now. I think the main point to clarify here is that the new V3 Create Event API is not a replacement for the Javascript track API you linked.

 

The Create Event API is a server-side endpoint that requires a private API key, which is why it has the permissions to update profiles. Although it has the capability to “track” events for profiles, it is not intended for the same use as the Javascript track API.

 

The Javascript API performs two functions, identifying (or cookie-ing), and tracking (transmitting events to Klaviyo for cookied profiles). There is another client-side endpoint that posts events with public key permissions called Create Client Event, but if you use this endpoint with an email/identifier that doesn’t exist, a new profile is created.

 

Therefore, this isn’t a behavior change between API revisions, but rather just the difference between two different API endpoints. Also, there is a later revision of our APIs than 2023-02-22, which is 2023-07-15. You can see the latest revision by opening the dropdown menu at the top left of our Developer portal:

 

 

I hope this helps to clarify!

 

Best,

Brian

Reply