Solved

How to add email to flow with ajax and api

  • 7 September 2021
  • 1 reply
  • 1061 views

Badge +2
This cod adding email to list but I cant add it to the flow I need.What I need to do? 

 

 $.ajax({
type: 'POST',
url: 'https://a.klaviyo.com/onsite/components/back-in-stock/subscribe',
data: {
a: 'api-key-public',
email: email,
variant: id,
platform: 'shopify'
},
success: function (response) {
console.log(response)
}

})

 

icon

Best answer by stephen.trumble 7 September 2021, 20:43

View original

1 reply

Userlevel 7
Badge +60

 

Hey@Michaellytvyn !

Thank you so much for reaching out to the Klaviyo Community for help with this!

You can utilize Klaviyo's client-side Back in Stock endpoint to submit Subscribed to Back in Stock events which will allow you to use the standard Back in Stock flow.Here's a sample AJAX request:

$.ajax({
  type: "POST",
  url: "https://a.klaviyo.com/onsite/components/back-in-stock/subscribe",
  data: {
    a: "ACCOUNT_ID", //replace with your account ID
    email: "EMAIL", // capture email address of customer
    variant: VARIANT_ID, // variant ID of product
    platform: "shopify",
    subscribe_for_newsletter: false, // OPTIONAL - false by default
    g: "LIST_ID", // OPTIONAL - if above is true this is the list to which a profile will be subscribed  },
  success: function(response){
    console.log(response)
  }
})

You can configure back in stock flow by adding a table block to the BIS flow email with your code. Also, Check out @rhino.lu Community Post about Back in Stock API and gathering more information from your customers. This post has additional resources to help you through more of this process.

Thank you for being part of the Klaviyo Community!

Reply