Solved

Klaviyo dropping events that are sent too close to each other

  • 16 September 2021
  • 2 replies
  • 28 views

Badge

Hello, I am working on integrating Klaviyo into an existing web page. I am having an issue where if I send events to Klaviyo, many of them don’t appear in Klaviyo. the post requests are all returning status code 200, so I assume that Klaviyo is recieving all of them. If I add a delay of 1 second between each request sent to Klaviyo, none of them get dropped. This seems to fix the issue, but it feels like a band-aid fix that’s just going to cause problems down the line, so I’d like to figure out why Klaviyo doesn’t seem to like multiple requests in quick succession. Usually I’m sending a placed order event, followed by anywhere from 2-12 ordered product events.

 

Here is the code I’m using to send the requests (written in vbscript):

Function SendJson(jsonString)
        Try
            Dim bytes = System.Text.Encoding.UTF8.GetBytes(jsonString)
            Dim request = WebRequest.Create("https://a.klaviyo.com/api/track")
            request.Method = "POST"
            request.ContentType = "application/json"
            request.ContentLength = bytes.Length
            Dim stream = request.GetRequestStream()
            stream.Write(bytes, 0, bytes.Length)
            stream.Close()
            Dim response = CType(request.GetResponse(), HttpWebResponse)

            If response.StatusCode <> 200 Then
                Return "Error: post request returned status code " + response.StatusCode + " for request:" + vbNewLine + jsonString
            End If
            Return "Request successful for request:" + vbNewLine + jsonString
        Catch exception As Exception
            Return "Error: " + exception.Message + "for " + jsonString + vbNewLine + exception.StackTrace
        End Try
    End Function

icon

Best answer by david.to 17 September 2021, 17:49

View original

2 replies

Userlevel 6
Badge +4

Hello @Jason,

Thanks for sharing your question with the Klaviyo Community!

Klaviyo’s Track api endpoint is actually very high throughput and therefore wouldn’t be rate-limited easily. When you mentioned triggering these metrics multiple times in quick succession, do these events happen to have the exact same event name and timestamps? If so then this is actually expected behavior. When multiple events have the same exact event name and timestamp, then they’re treated as duplicate events and ignored unless these events have a unique $event_id to distinguishing them as separate events. 

I’ve also attached some helpful Community posts below which touch upon this similar subject:

I hope this helps!

David

Badge

Figured out what the issue was. I had a unique event id for each request, but I was putting it in the top level of the JSON string instead of nesting it in properties. Changed that, and everything’s working perfectly.

Reply