The Noibu SDK (software development kit) allows you to interact with captured session data by creating custom attributes. Many customers use the SDK to pass data that allows them to pinpoint sessions related to specific campaigns, orders, A/B tests, and more.
The NoibuJS SDK is accessible from the global window object. The NOIBUJS attribute is set on the window object as soon as the Noibu script loads. Before using the SDK, check if the attribute is defined by running the function below:
async function checkSDKExistanceAndAddCustomAttribute() {
if (!window.NOIBUJS) {
await new Promise(resolve => {
window.addEventListener('noibuSDKReady', resolve);
});
}
window.NOIBUJS.addCustomAttribute('name', 'id');
}
checkSDKExistanceAndAddCustomAttribute();
This function checks if the window object has the NOIBUJS attribute. If the attribute is not available, it subscribes to the custom "noibuSDKReady" event, which is fired when the SDK is ready to use.
The addCustomAttribute Function
The addCustomAttribute function adds a custom attribute to the session you are working on, which helps you isolate it on the Noibu platform for later use. The attribute can be used to search Noibu sessions in a Session Search, and you can search by either the name or attribute value.
Common uses for the addCustomAttribute function include:
Use Case | Sample Code |
Create a custom attribute for Customer ID |
window.NOIBUJS.addCustomAttribute('customerID', '934739856') |
Create a custom attribute for a marketing campaign |
window.NOIBUJS.addCustomAttribute('campaign', 'BlackFridayCampaign') |
Create a custom attribute for an A/B test |
window.NOIBUJS.addCustomAttribute('variant', 'A') |
Create a custom attribute for logged in status |
window.NOIBUJS.addCustomAttribute('isLoggedIn', 'True') |
When filtering sessions by Custom Attributes, filtering on the name value returns all sessions where an id with that name appears. Searching by value only returns sessions where the value matches the value searched. If you want to match the name and value, then use both filters in a session search.
Note that you cannot add multiple custom attributes with the same attribute name. For example:
window.NOIBUJS.addCustomAttribute('customerID', 'ABC')
window.NOIBUJS.addCustomAttribute('customerID', 'DEF')
Will only result in the first custom attribute value ('ABC') being captured in Noibu.
Parameters
- name: String type (max 1024 characters) - The name of the attribute
- value: String type (max 1024 characters) - The value of the attribute
Limitations
- Once you add an attribute, you cannot edit the value of it. You can only add additional attributes.
- You can add a maximum of 10 attributes per page. Every time the user causes the page to reload counts as a new page. For example, if a user visits 10 pages, then you can have 100 attributes in that session.
- You cannot also use an object or number as a parameter; the function only takes strings.
The addError Function
The addError function allows you to create custom errors through the SDK. If you see an error occurring in a session, use this function to point out where it's happening. By examining several sessions where the error occurs, you can identify the money you may be losing due to the error.
The basic structure of the function is as follows:
window.NOIBUJS.addError(new Error(Error message))
Requirements
You must pass an error object to the addError function for the function to work.
The requestHelpCode Function
Through the requestHelpCode function, you can programmatically request a Help Code through the SDK. A help code identifies a shopper's unique session and allows support reps to associate a customer complaint to a session recording in the Noibu console.
The structure of this command is as follows:
window.NOIBUJS.requestHelpCode()
Use Cases
- A shopper can Generate a Help Code independently, but if a problem occurs you can use this API to access the help code.
- Several shoppers have requested a method of generating a help code without asking the shopper to modify their URL. With the
requestHelpCode
function, you can create a link or button that a shopper can click to generate the code. We recommend putting this link in your site's footer.- Note: To allow for clean filtering in the Sessions table, it's crucial that all help codes are generated deliberately, and creating a button may result in mis-clicks or bot activity generating erroneous help codes. To avoid this problem, we recommend assigning an unusual action to the help code button–right clicking or clicking four times, for example–to ensure that only shoppers instructed by CS can generate a help code.
Programmatic HelpCode Generation
If you desire to generate a helpcode without having to use the native browser's alert system you can use the Noibu SDK to generate the helpcode programmatically.
window.NOIBUJS.requestHelpCode(false)
This function returns a Promise which, once resolved, returns a string representing the helpcode for the current session. The below code shows the extraction of the helpcode.
NOIBUJS.requestHelpCode(false).then((helpcode) => {
console.log(helpcode);
}).catch(error => {
console.error('Error:', error); // In case there's an error in the promise.
});
Use Cases
- Embedding the helpcode directly in the contact us page upon a user navigating to that page.
- Automatic generation of the helpcode as soon as a customer engages in a support chat.
Video Walkthrough
Learn more about the Noibu Session ID, the Friction Factor, and Session Collection Failures.