Collections

The Gist JavaScript API

By Jitta

Updated 6 days ago

The Gist JavaScript library provides a Gist JavaScript object that responds to a few methods that allow you to update users without a page refresh and interact with the message window. Here is a guide to using the JavaScript API.

 Identifying Leads and Users with Gist JavaScript API

Here are the different types of Gist JavaScript API that you can use to connect to other apps.

1. When you want to track logged in uses; for instance, membership site or your SaaS app, and you want to send those users and their data to ConveretFox, use the following code.

convertfox.identify("123", {
	email: "email_address",
	name: "name",
	restaurant_type: "fine_dining"
});

Please note that for this code to work, user id and email are mandatory attributes. You can also add any number of optional attributes to pass on to Gist.

This is the only method you can use to identify logged in users/customers on Gist.

If you want to identify leads or subscribers who are not registered for a membership on your site or app, then you can use the following:

2. If you're sending only the email address and do not want to collect other attributes, then the syntax is:

convertfox.identify("email_address");<br>
	

3. If you wish to send other custom attributes along with the email address, then the syntax is:

convertfox.identify({
	email: "email_address",
	name: "name",
	restaurant_type: "fine_dining"
});<br>
	

4. This is another variation of the syntax above. If you are already using JavaScript code for identifying loggged in users, as mentioned in 1., then you can use the same syntax, along with an empty string for user ID.

convertfox.identify("", {
	email: "email_address",
	name: "name",
	restaurant_type: "fine_dining"
});
	

Gist JavaScript API for Chat Messenger

Following is the JavaScript API you can call to show, hide, or load the Gist chat messenger on specific pages and to specific users.

Identifying users and user properties

If you'd like to choose when the Gist messenger must load, on what pages, and to which users, you can use the convertfox.identify method.

convertfox.identify("12345", {
"email":  "johndoe@tacos.com",
"name": "John Doe",
"user_id": "12345"
"subdomain":  "app",
"last_paid_at" : 1283495946,
});

This is useful in situations where you have a restricted area of members or users and you want the chat messenger to be shown only to them and not to anyone else. For more information on the convertfox.identify call, please refer to this document.

Display the chat messenger

This will display the Gist chat messenger on the page on which this API is called. 

If there are no previous conversations with the user, it will open with the new message view. If, however, there are previous conversations with that user, if there are it will open with the message list. To make this happen, you can call the following API.

convertfox.chat('show')

You can use this API call to show the chat messenger only on specific pages of your website, such as your 'app' or member login area.

Hide the chat messenger

This call will hide the Gist chat messenger panel if it is open on that particular page. It will not hide the Messenger Launcher everywhere in general, but just hides on those pages where this script loads. To make this happen, you can call the following API.

convertfox.chat('hide');

This is useful if you want to hide the chat messenger by default on a page and only display it when an event is triggered by your users, such as clicking a link or a button.

Launch Gist Messenger on Button Click

You can set up Gist to launch the chat messenger when your users perform a specific event on your website, such as clicking a link or a 'Contact Us' button. To make this happen, you can call the following API.

convertfox.chat('openNewConversation');

For example, you can add a link anywhere on your site, including HTML text or buttons on a particular page, which when clicked will load the Gist chat messenger ready for a new conversation. This can be used to enable chat to only those users that perform those actions and avoid everyone else.

Example use cases:

API call for loading the chat messenger on link click:

If you have any questions about our pricing, please <a href="#" onclick="convertfox.chat('openNewConversation')">contact our support team</a>

API call for loading the chat messenger on a button click:

<a class="btn" href="#"onclick="convertfox.chat('openNewConversation')">Contact Us</a>

You can use these two API calls to use a custom launcher for the chat messenger on a specific page.

For instance, if you do not wish to display the chat messenger by default, but only launch it when a user clicks on a link or button on that page, you can use a combination of the convertfox.chat('hide'); and convertfox.chat('openNewConversation'); calls to achieve this.

Did this answer your question?