Skip to content

Instantly share code, notes, and snippets.

@cbarley10
Last active February 11, 2020 18:16
Show Gist options
  • Save cbarley10/cd1a167d76f1b50624ec495bc223c47d to your computer and use it in GitHub Desktop.
Save cbarley10/cd1a167d76f1b50624ec495bc223c47d to your computer and use it in GitHub Desktop.
Kind Snacks Custom Form Add Profile to List
<script type="text/javascript">
var form = $(".c-email-signup__form.js-subscribe")[0];
var user = {
email: ""
};
/* CHANGE LIST ID HERE */
var listID = "somelistID"
/* CHANGE LIST ID HERE */
var subscribeButton = $(".c-email-signup__form.js-subscribe .c-email-signup__button.js-subscription-submit")[0];
form.addEventListener("change", function(e){
user["email"] = e.target.value
})
subscribeButton.addEventListener("click", function(){
_learnq.push(["identify", {
"$email": user.email
}])
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": listID,
"$fields": "$email",
"email": user.email,
"$source": "Custom Form"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment