Hey, I tried literally everything to add an subscribe to Back in Stock event via the Klaviyo API (Shopify) as described here but it’s not working. I also searched the forums and tried all the provided solutions, but none of them worked.
What I tried
- We have a Shopify live store and a development store. They are not connected in any way. I created a second Klaviyo “Dev” account so that we can play around on the Dev store
- I added the javascript code to my website. I tried different codes. Self-written, from the docs and code which I found here on the forum
First Code Attempt
fetch("https://a.klaviyo.com/onsite/components/back-in-stock/subscribe", {
"headers": {
"accept": "application/json, text/plain, */*",
"content-type": "application/x-www-form-urlencoded;charset=UTF-8",
},
"body": new URLSearchParams({
"a": "my_public_api_key",
"email": "myemail@gmail.com",
"platform": "shopify",
"variant": 43686047940889,
"product": 7978217177369,
}),
"method": "POST",
})
.then(response => {
console.log(response);
})
.catch(err => {
console.error(err);
});
Second Code Attempt
$.ajax({
type: "POST",
url: "https://a.klaviyo.com/onsite/components/back-in-stock/subscribe",
data: {
a: "ACCOUNT_ID", // Klaviyo account public token
email: "EMAIL", // Email address entered in form
variant: VARIANT_ID, // ID of the out of stock product variant about which customer wants to be notified.
platform: "shopify",
},
success: function(response){
console.log(response)
}
})
… and a few more.
I always got the same result:

I tried it locally as well as from the Dev environment (https://my-shopify-dev-store.myshopify.com). My Dev Klaviyo account is connected to the Shopify Development Store.
The Development Store is only reachable by password, could this be the problem? Is there anything else I need to set up inside my Klaviyo account in order to get this working?