Note: Connect will be deprecated and removed on October 31, 2021. See Removal of Zendesk Connect.

You can use the Connect JavaScript library to send user and event data to Zendesk Connect. The library is designed to run in the user's browser. For server-side JavaScript applications, use the Node.js module.

This document covers the following topics:

Add the JavaScript snippet to pages

Insert the following snippet at the bottom of your pages, before the closing body tag:

<script type="text/javascript"> !function(e,t){if(!window.outbound){for(var n=window.outbound=[],o=["identify","track","handlePush","registerApnsToken","registerGcmToken","disableApnsToken","disableGcmToken"],r=0;r<o.length;r++){var i=o[r];n[i]=function(e){return function(){var;return t.unshift(e),n.push(t),n}}(i)}if(!e.getElementById("outbound-js")){var s=e.createElement("script");s.type="text/javascript","outbound-js",s.async=!0,s.src=""+t+".js";var u=e.getElementsByTagName("script")[0];u.parentNode.insertBefore(s,u)}}}(document,"PUBLIC_KEY"); </script>

Find and replace the PUBLIC_KEY placeholder near the end of the snippet. Unlike the other libraries, you must specify a public key, not a private one, to authenticate requests to Connect. For more information, see Authentication in the introduction.

Identify a user

Use the outbound.identify() method to send user data to Connect. The method takes the following positional arguments:

  • a string containing the user id
  • an object containing the user attributes. Only the property names in the example below are supported. All are optional


var userAttributes = {  firstName: 'Jane',  lastName: 'Doe',  email: '[email protected]',  phoneNumber: '+1 555-123-4567',  apnsTokens: ['ios device token'],  gcmTokens: ['android device token'],  previousId: 'anonymous_user_123',  attributes: {    membership_level: 'Gold'  }};outbound.identify('4512345', userAttributes);

The method stores and updates the user id in a cookie.

For more information, see Users.

Track an event

Use the outbound.track() method to send event data to Connect. The method takes the following positional arguments:

  • a string containing the event name
  • (optional) an object containing custom event properties. See Properties attribute in the Events documentation

Note: The method doesn't specify a user id as an argument. Instead, it gets the user id from a cookie.


eventProperties = {  membership_renewalDate: '2018-06-12'};outbound.track('renewMembership', eventProperties);

For more information about the arguments, see Events.

The track() method sends the data to Connect as soon as it runs, so make sure it has access to the user and event data.