Hi,
I am trying to connect my squarespace website to Kaviyo and trigger a flow when a customer complete a purchase. I have been trying to add code to the footer of the oder details page following the Kaviyo API guide. However I still couldn’t get it to work. I have a few questions:
- Do we need to make a call to /identity and then /track?
- I tried to do something like :
<script type="text/javascript">
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://a.klaviyo.com/api/identify", true);
xhr.onreadystatechange = function(){
if(xhr.readyState === 4 && xhr.status === 200) {
var x = new XMLHttpRequest(); x.open("POST", "https://a.klaviyo.com/api/track",false); x.send(JSON.stringify({
"token": "xxxxx",
"event": "Placed Order",
"customer_properties": {
"$email": "ttesting" ,
} }));
}
}
xhr.send(JSON.stringify({
"token": "xxxxx",
"properties": {
"$email": "ttesting"
}
}));
</script>
But they didnt work. So I tried the frontend call method and did something like:
This time it somehow works, and there is a custom matrix called “Placed Order” (different than the default one) shows up. So I was trying to use this custom “Placed Order” to trigger a flow. However this call only works once. I tried to place a several test orders and this matrix is not triggered:
May I get some help please? Thanks a lot.
Many thanks,
Meiya