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