_scq.push([
  "identify",
  {
    email: "john.doe@gmail.com",
    firstName: "John",
    lastName: "Doe",
    birthday: "1989-03-03",
    customFields: {
      Designation: "Software Engineer",
      Age: "27",
      Experience: "5",
    },
    tags: ["Developer", "API Team"],
  },
]);
  {
    "status": "200",
    "message": "OK",
  }

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.

_scq.Push(["methodName", { key: "value", ... }]);

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.

_scq.push([
  "identify",
  {
    email: "john.doe@gmail.com",
    firstName: "John",
    lastName: "Doe",
    birthday: "1989-03-03",
    customFields: {
      Designation: "Software Engineer",
      Age: "27",
      Experience: "5",
    },
    tags: ["Developer", "API Team"],
  },
]);

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 by 34
    • "customField_name": "--10" → Decreases the current value by 10

    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

identify.js
_scq.push([
  "identify",
  {
    email: "john.doe@gmail.com",
    firstName: "John",
    birthday: "1989-03-03",
    customFields: { Designation: "Software Engineer" },
    tags: ["Developer"],
    success: function () {
      console.log("identify call successful");
    },
    failure: function () {
      console.log("identify failed");
    },
  },
]);

API Call B

identify.js
_scq.push([
  "identify",
  {
    email: "john.doe@gmail.com",
    customFields: { Age: "29" },
    tags: ["API Team"],
    success: function () {
      console.log("identify call successful");
    },
    failure: function () {
      console.log("identify failed");
    },
  },
]);

Then the final contact will look like this:

{
  "firstName": "John",
  "email": "john.doe@gmail.com",
  "birthday": "1989-03-03",
  "customFields": {
    "Designation": "Software Engineer",
    "Age": "29"
  },
  "tags": [
    "Developer",
    "API Team"
  ]
}

Values are merged, not overwritten wholesale. You only need to send what you want to add or update.

Identify Properties

PropertyTypeDescription
firstNamestringContact’s first name
lastNamestringContact’s last name
emailstringContact’s current email address (used to identify the contact)
newEmailstringNew email address if updating an existing contact
companystringCompany name
birthdaystring (YYYY-MM-DD)Date of birth (e.g., 2016-11-21)
customFieldsmap[string]stringKey-value pairs for custom fields (e.g., {"Designation": "Engineer"})
tagsarray of stringList of tags associated with the contact (e.g., ["Developer", "API Team"])
successfunction (optional)Callback executed upon a successful request
failurefunction (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.

  {
    "status": "200",
    "message": "OK",
  }

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

PropertyTypeDescription
addTagsarray of stringTags to add to the contact (e.g., ["Developer", "Onboarding"])
removeTagsarray of stringTags to remove from the contact
successfunction (optional)Callback executed when the request completes successfully
failurefunction (optional)Callback executed when the request fails or times out