Account Defense - Login

The NeuroID JavaScript Library is customized for your Site Id and hosted on NeuroID servers. It enables specific versions of the library as per your configuration.

Account Defense

The account defense integration should be used on the login flow of your web application, as well as post login flows that should be protected.

Authentication

Basic authentication is used, and your key will be integrated into your configuration, loaded by the JS snippet you're using. For any questions, contact our Implementation Engineering team at [email protected].

Integration Steps

The following steps will walk you through implementing the NeuroID JavaScript Library.

1. Install the JavaScript with the Collection SiteId

If this is the first time you are integrating with the JS library, you must load the collection snippet. If you already have configured a collection snippet on your application, you can skip to step 3.

<!-- The following Snippet is for Test Purposes Only -->
<script type="text/javascript">
  (function(n,e,u,r,o,i,d){
       n.nid=n.nid||function(){(n.nid.q=n.nid.q||[]).push(arguments)};
       o=e.createElement(u);i=e.getElementsByTagName(u)[0];o.async=1;
       o.src=r;i.parentNode.insertBefore(o,i);
  })(window,document,'script','//scripts.neuro-id.com/c/nid-YOUR_COLLECTION_SITEID_HERE-test.js');
</script>
<!-- The following Snippet is for Production -->
<script type="text/javascript">
  (function(n,e,u,r,o,i,d){
       n.nid=n.nid||function(){(n.nid.q=n.nid.q||[]).push(arguments)};
       o=e.createElement(u);i=e.getElementsByTagName(u)[0];o.async=1;
       o.src=r;i.parentNode.insertBefore(o,i);
  })(window,document,'script','//scripts.neuro-id.com/c/nid-YOUR_COLLECTION_SITEID_HERE.js');
</script>

Embed this JavaScript snippet within the <head> section of your webpage. This snippet may be retrieved from the JavaScript Installation Settings page in the NeuroID Portal or copied from here.

2. Update the JavaScript with your Collection SiteId

The Collection SiteId is the siteId used to collect data across all flows of your web application.

If you copy the snippet from here, you must update your JavaScript snippet URL. Your URL will look similar to: //scripts.neuro-id.com/c/nid-abcde123.js.

If you copied your snippet from the NeuroID Portal, please continue to Step 3.

If you receive a siteId from NeuroID in the format form_abcde123, you need to remove form_ prefix before using for example the value e.g. abcde123 in your JS snippet.

📘

A NeuroID siteId uniquely identifies the Application form for which behavioral data is collected. The format consists of the prefix form_ followed by five characters and then three numbers (e.g.,form_abcde123). It is important that you do not reuse a siteId across multiple forms or applications. Each must be unique.

Collection SiteId - The siteId used to collect data across your web application

Use Case SiteId - The siteId used to designate different flows of your application. For example: onboarding, login, navigation, account details.

👍

Your JavaScript snippet URL will look similar to

//scripts.neuro-id.com/c/nid-abcde123.js.

In this example, the siteId would be form_abcde123.

3. Set LinkedSiteId with your Use Case siteId

The setLinkedSiteId command sets data collection for a given use case.

nid('setLinkedSiteId', 'siteId'); 

4. Store NeuroID sessionId

NeuroID sessionId identifier is automatically generated as soon as the NeuroID JavaScript loads and data collection auto-start.

❗️

Storing NeuroID sessionId

The NeuroID dashboard and alerts use a generated NeuroID identifier as the primary key for user tracking and analytics. You can retrieve this identifier programmatically using the following command:

nid.getUserId();

Additionally, the NeuroID identifier (nid_sid) is stored in the browser's session storage. You can access it directly from there if needed.

To ensure seamless tracking and integration, the NeuroID identifier must be linked to your internal customer identifier. This allows for a unified view across your internal systems and the NeuroID platform.

This identifier is essential for reviewing NeuroID dashboards and alerts.

5. Label Input Fields

Ensure you use descriptive names for your input fields. These will be used during configuration to identify each input field. If you do not have descriptive names, we recommend incorporating unique, stable, and descriptive data-nid-target attributes into your input fields, e.g., data-nid-target="username" if the input field is a username field. Please refer to our data-nid-target documentation for more information.


JavaScript Installation Complete 🎉

Your JavaScript installation is now complete.
Please contact NeuroID at [email protected] to complete your site's configuration.

Visit the Advanced Functions documentation to learn more about NeuroID JavaScript functions not covered here.