SendX JS Client Library
Configure your client side to track and identify visitors to your application
The SendX JS Client library enables you to seamlessly capture contacts, assign tags, and update custom fields directly from your website. This guide walks you through installing the snippet, sending asynchronous API requests, and using available methods like identify and track to personalise and automate your marketing workflows.
Installing Javascript Snippet
To use SendX JS Client library you need to have SendX snippet installed on your website. Each SendX team account has a unique snippet that can be found under Settings > Site Code Snippet
SendX Javascript snippet gets loaded asynchronously and hence it won’t affect page load time of your website.
Sending API Requests
All requests follow the same pattern.
API requests are executed asynchronously so you can safely place them anywhere on the page. The conventions are similar to what google analytics API follows.
API Methods
SendX Javascript Client library has two methods:
- Identify
- Track
Identify API Method
Identify API Method is used to attach data to a visitor. If a contact is not yet created then we will create the contact. In case contact already exists then we update it.
Tags:
tags
is an array of strings.- If a tag does not exist, it is automatically created and associated with the contact.
Custom Fields:
-
If a custom field does not exist, it will be created with **type **
string
and the value will be set. -
If the field already exists, the value will be updated.
-
Custom fields can also have type
number
. To modify them incrementally, use:"customField_name": "++34"
→ Increases the current value by34
"customField_name": "--10"
→ Decreases the current value by10
If the custom field does not already exist, the numeric value (e.g. 34) is directly set as the starting value.
Identify Calls are Additive
The identify
call does not delete any previously set properties.
API Call A
API Call B
Then the final contact will look like this:
Values are merged, not overwritten wholesale. You only need to send what you want to add or update.
Identify Properties
Property | Type | Description |
---|---|---|
firstName | string | Contact’s first name |
lastName | string | Contact’s last name |
email | string | Contact’s current email address (used to identify the contact) |
newEmail | string | New email address if updating an existing contact |
company | string | Company name |
birthday | string (YYYY-MM-DD) | Date of birth (e.g., 2016-11-21 ) |
customFields | map[string]string | Key-value pairs for custom fields (e.g., {"Designation": "Engineer"} ) |
tags | array of string | List of tags associated with the contact (e.g., ["Developer", "API Team"] ) |
success | function (optional) | Callback executed upon a successful request |
failure | function (optional) | Callback executed when the request fails or times out |
In case email of an already existing contact needs to be updated then specify current email under email property and updated email under newEmail
property.
Track API Method
Track API Method is used to track a contact. You can add or remove tags from a contact using this API.
Track Properties
Property | Type | Description |
---|---|---|
addTags | array of string | Tags to add to the contact (e.g., ["Developer", "Onboarding"] ) |
removeTags | array of string | Tags to remove from the contact |
success | function (optional) | Callback executed when the request completes successfully |
failure | function (optional) | Callback executed when the request fails or times out |