Skip to main content
Solved

How to add email to flow with ajax and api

  • September 7, 2021
  • 1 reply
  • 1132 views

Forum|alt.badge.img+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)
                        }

                    })

 

Best answer by stephen.trumble

 

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!

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

stephen.trumble
Community Manager
Forum|alt.badge.img+60
  • Community Manager
  • 1518 replies
  • Answer
  • September 7, 2021

 

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!