Skip to content

Instantly share code, notes, and snippets.

@spasiu
Last active February 12, 2016 19:24
Show Gist options
  • Select an option

  • Save spasiu/1170a706d43c34b2f1ef to your computer and use it in GitHub Desktop.

Select an option

Save spasiu/1170a706d43c34b2f1ef to your computer and use it in GitHub Desktop.
get name for smooch user
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form class="name-collecting-form">
<input type="text" name="givenName" placeholder="given name">
<button>submit</button>
</form>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://cdn.smooch.io/smooch.min.js"></script>
<script>
$(document).ready(function() {
$('.name-collecting-form').submit(function(e) {
e.preventDefault();
init(e.target.givenName.value);
});
});
function init(givenName) {
Smooch.init({
appToken: '5nwcd6kl3maocv0n31mp4ymtt',
givenName: givenName
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment