January 12, 2022

JS API integration

This article explains where to find the JS API and how to get started with the integration. It is designed to assist developers with end-side product integration. More detailed information about the JS API is available here.

JS API can be installed using Google Tag Manager.

Things to know before starting

  • User activity is tracked exclusively for registered individuals and only after the JavaScript script has been executed. Anonymous or unregistered sessions are not recorded.
  • To update existing user variables, re-execute the JS API call. This request must include the user's unique identifier along with any updated attribute values.
  • Existing variables within a profile will be overwritten with new data. Any previously undefined variables included in the call will be appended to the profile.
  • If a contact is already present in the contact list, their primary identification method cannot be modified via this call.
  • While the JavaScript API provides a simplified implementation, it is optional. Full functionality is also accessible via the REST API.
  • Important! To ensure proper JS API functionality, please enable all required permissions. Any methods left unchecked will remain inactive.

Step-by-step instructions

  • Navigate to the “Apps & Add-ons” page.

  • Press the “JavaScript API” button.

  • Click the "Add website" button.

  • Select the domain name.

  • Configure the required options and permissions using the checkboxes. Note: the code snippet updates dynamically based on selections.

  • Click the "Save" button.

  • Copy the generated code and embed it into the HTML of the desired pages.

    • Deployment of the same code across multiple pages is permitted; in this case, all subscribers will be consolidated into the Default Contact List.
    • Ensure that at least one unique identifier (userId, email, or phoneNumber) is included so the system can match the contact to the existing database.
  • Download and extract the Worker File from the archive, then upload it to the website's root directory.

  • Place the JS initialization and user identification snippets immediately before the closing </body> tag on every page to ensure proper API functionality.

Verifying Successful Integration

  • Navigate to the “Apps & Add-ons” page.

  • Press the “JavaScript API” button.

  • The installation is validated upon the first successful JS API call, automatically updating the status to “Connected.”

  • If the status remains “Not connected,” a thorough review of the configuration and applied settings is required.

  • Once the “Connected” status is achieved, full functionality becomes available, including creating and updating contacts, managing user data, and managing subscriptions.

JS API integration connection