Web Portals

Collect the encrypted browser payload with the JavaScript SDK and forward it to your backend to register the login event with SmartID.

SDK Installation

Before integrating, install the SDK in Getting Started → Install the SDK →

personalization_raw

Collects browser and device fingerprint data synchronously and returns the encoded payload as a string. Call this in the onload of the login page.

JavaScript
// call on page load, before the user submits credentials
const smartidData = personalization_raw();

// attach to the hidden input — empty string if the call returned nothing
document.getElementById('smartid-data').value = smartidData || '';
Web Integrity — prior call required

If you use the Web Integrity rule, call personalization_integrity() before personalization_raw() so that site integrity data is captured in the payload.

Include in the login form

Add a hidden input to carry the payload on form submission.

HTML
<form action="/api/login" method="POST">
  <input type="text"     name="username"    placeholder="Username" />
  <input type="password"  name="password"    placeholder="Password" />
  <input type="hidden"   name="smartid_data" id="smartid-data" />
  <button type="submit">Login</button>
</form>

Complete login flow

The SDK runs in the user's browser. Only your backend calls the SmartID API.

1

SDK collects data in the browser

When the login page loads, call personalization_raw(). It returns the encoded payload synchronously and writes it into the hidden input.

2

Form sends credentials + payload to your backend

On submit, the form posts username, password, and the hidden smartid_data field to your server. If the SDK failed, the field is empty.

3

Your backend calls the SmartID API

Your server POSTs the login event to SmartID with the user attributes and encrypted payload.

POST /api/v5/analytics/web/login
cURL
curl -X POST https://<api-url>/api/v5/analytics/web/login \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer <license>" \\
  -d '{
    "channelId": 1,
    "user": "jlopez",
    "session": "445613456fa",
    "publicIp": "20.201.64.54",
    "data": "<smartid_data from the form, empty string on failure>"
  }'
Field Type Required Description
channelIdintegerRequiredYour SmartID channel identifier
userstringRequiredUsername or unique user identifier
sessionstringOptionalYour application session token
publicIpstringRequiredUser's public IP address
datastringRequiredPayload from getRawData. Empty string if SDK failed.
4

SmartID returns 200 OK

SmartID logs the event and responds with 200 OK. Proceed with your normal login logic.

Logout

When the user logs out, notify SmartID from your backend. No SDK call is needed from the browser.

POST /api/v5/analytics/web/logout
cURL
curl -X POST https://<api-url>/api/v5/analytics/web/logout \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer <license>" \\
  -d '{
    "channelId": 1,
    "user": "jlopez",
    "session": "445613456fa"
  }'
Optional fields on logout

publicIp and data are optional on logout. channelId, user, and session are sufficient to close the event.