Skip to content

Instantly share code, notes, and snippets.

@nielsfogt
Created September 13, 2019 23:36
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 nielsfogt/d9d5ce702f6bc4b2e1218791de381b9b to your computer and use it in GitHub Desktop.
Save nielsfogt/d9d5ce702f6bc4b2e1218791de381b9b to your computer and use it in GitHub Desktop.
form.onSuccess(function(vals) {
var visitorId = Intercom("getVisitorId");
var payload = JSON.stringify({
anonId: visitorId,
vals: vals
});
// Setup our http client
var xhttp = new XMLHttpRequest();
// Add Public Workflow URL from Tray Platform webhook workflow.
xhttp.open("POST", "TRAY_WEBHOOK_URL", true);
// Set a few request headers
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.setRequestHeader("X-CSRF-Token", "YOUR_TOKEN");
// Send payload to the Tray Platform, bon voyage!
xhttp.send(payload);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment