Skip to content

Instantly share code, notes, and snippets.

@luizfaias
Last active May 9, 2018 15:41
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 luizfaias/ebefc4159ddd155f3fdd9ffff26c6c19 to your computer and use it in GitHub Desktop.
Save luizfaias/ebefc4159ddd155f3fdd9ffff26c6c19 to your computer and use it in GitHub Desktop.
Zendesk Chat - identify customer and show widget
<script>
<!-- Opens the chat widget automatically
Example: https://SUBDOMAIN.zendesk.com/hc?start_chat=true&customer_name=John&customer_email=john@example.com
-->
jQuery.extend({
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
});
var queryParams = $.getQueryParameters();
if(queryParams["start_chat"]) {
zE(function() {
zE.identify({
name: queryParams["customer_name"],
email: queryParams["customer_email"]
});
zE.activate();
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment