Skip to main content
Solved

How to create AJAX Request and what's the endpoint(URL) where I use my form in which I have two fields email and message(textarea) to collect user email and message?

  • December 17, 2022
  • 1 reply
  • 1866 views

Forum|alt.badge.img+2

Hi Klaviyo Community Have a Good Day😊

I’m working on a shopify project and want to collect user email and message in Klaviyo. I want to use my own popup form(email, message fields and a submit button) and send AJAX request to Klaviyo. Please help me what’s the endpoint where AJAX request send to like https://manage.kmail-lists.com/ajax/subscriptions/subscribe but it’s provide information whether the user is subscribed to a specific email.

 

 

Below is my code:

requestSwatchForm.addEventListener('submit', function(e) {

e.preventDefault();

 

var settings = {

"async": true,

"crossDomain": true,

"url": "https://manage.kmail-lists.com/ajax/subscriptions/subscribe",

"method": "POST",

"headers": {

"content-type": "application/x-www-form-urlencoded",

"cache-control": "no-cache"

},

"data": {

"g": "S2RrTD", // replace LIST_ID with id of list to be subscribed

"email": "abidarif982@gmail.com",

 

// pass in additional fields, each additional field

// must be included in the $fields string separated by commas

"$fields": "$message, $first_name, $last_name",

"$message": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis",

"$first_name": "Abid",

"$last_name": "Arif"

}

};

$.ajax(settings).done(function(response) {

console.log(response);

})

});

Best answer by Brian Turcotte

Hi @abidarif and welcome to the Community!

 

If you are attempting to check which lists a user is already subscribed to, then I would suggest using this endpoint:

If you are looking to actually subscribe a user to a list, then it would make sense to use this endpoint:

At this time, we don’t provide in-depth customization help for custom/legacy forms as mentioned in our Legacy Signup Forms vs. Built-In Signup Forms Help Center article, but you can always reach out to one of our wonderful Partner Agencies for development assistance or post in our Community Job Board!

 

I hope this helps get you started, and thanks for using the Community!

- Brian

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

1 reply

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • December 19, 2022

Hi @abidarif and welcome to the Community!

 

If you are attempting to check which lists a user is already subscribed to, then I would suggest using this endpoint:

If you are looking to actually subscribe a user to a list, then it would make sense to use this endpoint:

At this time, we don’t provide in-depth customization help for custom/legacy forms as mentioned in our Legacy Signup Forms vs. Built-In Signup Forms Help Center article, but you can always reach out to one of our wonderful Partner Agencies for development assistance or post in our Community Job Board!

 

I hope this helps get you started, and thanks for using the Community!

- Brian