As Joyned's script is loaded, it has all the information that the plugin needs in order to function properly and to be configured as it was requested by the customer.
Sometimes some data is not available when the main script is loaded. To solve this issue, we have created the customer API.
Getting the customer API object
There are 2 ways to get the customer API object from the Joyned script.
- Adding the callback parameter.
- Using the global object.
When loading Joyned's script, a callback parameter can be added.
After loading Joyned, the script will be looking for the callback function on the window object and will execute it, providing the JoynedCustomerAPI object to that function.
If the callback parameter is not provided, a global object with the name `joynedCustomerAPI` will be set on the global window object.
Using the customer API object
After you have an instance of customer API object you can call one of the following functions from this object.
`setExternalId(externalId: string): void`
This is a function used to set a unique identifier for the current user to identify it for analytics purposes. The external unique identifier is used to identify the same user when the hosting customer can identify the same user in several different platforms but Joyned has no permissions for that.
- Use that option when you have a network of websites that has the same users but different domains or you use a different systems, one for collecting the website offerings and the other to checkout.
- The best external identifier can be your own identification strings or one provided by external systems like Google Analytics. It's not recommended to use meaningful identifiers like emails or phone numbers for security reasons.