Skip to content

Instantly share code, notes, and snippets.

@yazinsai
Created November 11, 2020 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yazinsai/cc6cc2119b4420c86edd15e1f1b1b611 to your computer and use it in GitHub Desktop.
Save yazinsai/cc6cc2119b4420c86edd15e1f1b1b611 to your computer and use it in GitHub Desktop.
A simple script to register a user to ConvertKit using only Javascript
/* Submit an email address to ConvertKit using only Javascript */
function submitForm(email) {
fetch('https://app.convertkit.com/forms/XXXXXX/subscriptions', {
// replace XXXXXX above with your form ID (e.g. 1231234)
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `email_address=${email}`
}).then((response) => {
// TODO: Show a message that the subscription was successful!
});
}
// That's it!
// Use like so: submitForm("elon@spacex.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment