Auth - Attribute
Identify users by passing identity as data-* attributes on the widget loader script tag. No backend required.
How it works
Add user identity fields as data-* attributes on the widget loader script tag. The loader reads these attributes and uses them to identify the user with Returning.AI.
<script
src="https://prod-widgets.returning.ai/widget-loader.js"
data-widget-id="YOUR_WIDGET_ID"
data-widget-type="custom"
data-container="returning-ai-widget-YOUR_WIDGET_ID"
data-email="user@example.com"
data-api-url="https://prod-widgets.returning.ai"
data-widget-url="https://prod-widgets.returning.ai/custom-widget"
></script>Common attributes
| Attribute | Description |
|---|---|
| data-email | User email address. The most common identifier. |
| data-user-id | Your internal user ID. |
| data-firstname | User first name. |
| data-lastname | User last name. |
Security through stacking
The more attributes you include, the harder it is for someone to spoof the identity. Stack email + userId + custom fields for stronger identification.
<script
src="https://prod-widgets.returning.ai/widget-loader.js"
data-widget-id="YOUR_WIDGET_ID"
data-widget-type="custom"
data-container="returning-ai-widget-YOUR_WIDGET_ID"
data-email="user@example.com"
data-user-id="USR-9a3f2b"
data-firstname="Jane"
data-custom-tier="gold"
data-theme="dark"
data-api-url="https://prod-widgets.returning.ai"
data-widget-url="https://prod-widgets.returning.ai/custom-widget"
></script>Dynamic attribute building
If your user data is available in JavaScript, build the script tag dynamically:
// Build the widget loader script tag dynamically
const script = document.createElement('script');
script.src = 'https://prod-widgets.returning.ai/widget-loader.js';
script.dataset.widgetId = 'YOUR_WIDGET_ID';
script.dataset.widgetType = 'custom';
script.dataset.container = 'returning-ai-widget-YOUR_WIDGET_ID';
script.dataset.email = user.email;
script.dataset.userId = user.id;
script.dataset.firstname = user.firstName;
script.dataset.apiUrl = 'https://prod-widgets.returning.ai';
script.dataset.widgetUrl = 'https://prod-widgets.returning.ai/custom-widget';
document.getElementById('widget-container').appendChild(script);When to use
- CMS platforms where you can template user data into the script tag.
- Static sites with known users.
- Quick prototyping before implementing Access Key Embed.
Custom attributes
Any field that exists on both the client side and the Returning.AI platform can be passed as a data-* attribute. Custom fields can be created in the admin panel to add layers of identity verification.
Need server-verified identity? Use the Widget SDK with Access Key Embed for server-verified authentication.