Data Attributes

HTML attribute configuration reference for the embed script

Configure the embed using HTML data attributes on the script tag. No JavaScript required for basic setup.

Required Attributes

These attributes must be present for the embed to work.

AttributeTypeDescriptionRequired
data-client-keystringClient key from Create Client Key APIYes
data-agent-idstringAgent ID from Create AgentYes

UI Attributes

Control the appearance, layout, and visibility of the agent interface.

AttributeTypeDefaultValid ValuesDescription
data-modestringfabiofabio, fullDisplay mode
data-positionstringrightright, leftPosition of widget (fabio mode)
data-target-idstring-Any valid DOM element IDTarget element ID (required for full mode)
data-orientationstringverticalvertical, horizontalLayout orientation
data-open-modestringcompactcompact, expandedInitial display state
data-show-restart-buttonstringtruetrue, falseShow restart conversation button
data-show-agent-namestringtruetrue, falseShow agent name in the interface

Display Modes

fabio (default) - Floating action button that opens in an overlay

<script
  type="module"
  src="https://agent.d-id.com/v2/index.js"
  data-mode="fabio"
  data-client-key="{client_key}"
  data-agent-id="{agent_id}"
></script>

full - Render inside a specific container

<div id="agent-container"></div>

<script
  type="module"
  src="https://agent.d-id.com/v2/index.js"
  data-mode="full"
  data-target-id="agent-container"
  data-client-key="{client_key}"
  data-agent-id="{agent_id}"
></script>

Position and Orientation

<!-- Position on the left (fabio mode) -->
<script data-mode="fabio" data-position="left" ...></script>

<!-- Vertical layout - avatar on top, chat below -->
<script data-orientation="vertical" ...></script>

<!-- Horizontal layout - avatar and chat side by side -->
<script data-orientation="horizontal" ...></script>

Display State

<!-- Start compact - just the button visible -->
<script data-open-mode="compact" ...></script>

<!-- Start expanded - agent interface immediately visible -->
<script data-open-mode="expanded" ...></script>

UI Element Visibility

<!-- Hide restart button -->
<script data-show-restart-button="false" ...></script>

<!-- Hide agent name -->
<script data-show-agent-name="false" ...></script>

<!-- Hide multiple UI elements -->
<script
  data-show-restart-button="false"
  data-show-agent-name="false"
  data-client-key="{client_key}"
  data-agent-id="{agent_id}"
></script>

Behavior Attributes

Control agent connection and interaction behavior.

AttributeTypeDefaultValid ValuesDescription
data-auto-connectstringfalsetrue, falseConnect automatically on page load
data-speech-silence-timeout-msstring500msNumber (ms)Silence timeout for speech detection

Tracking Attributes

Control analytics and user identification.

AttributeTypeDefaultValid ValuesDescription
data-trackstringtruetrue, falseEnable event tracking
data-external-idstring-Any stringCustom user/session identifier
data-mixpanel-keystring-Any stringCustom Mixpanel project key
data-mixpanel-property-*string-Any stringCustom Mixpanel event properties

data-external-id

Pass custom identifiers to link agent conversations to your user system.

<!-- Static ID -->
<script data-external-id="session_abc123" ...></script>

Use cases:

  • Link conversations to CRM records
  • Track specific customer sessions
  • Segment analytics by user type
  • Compliance and audit trails

data-mixpanel-key

Override the default Mixpanel project key with your own for custom analytics pipelines.

<script data-mixpanel-key="your_mixpanel_project_token" ...></script>

data-mixpanel-property-*

Add custom properties to Mixpanel events. Any attribute starting with data-mixpanel-property- is automatically extracted and included in analytics events.

<script
  data-mixpanel-property-plan="enterprise"
  data-mixpanel-property-region="us-east"
  data-mixpanel-property-team="support"
  ...
></script>

Runtime Configuration

Many attributes can also be changed dynamically at runtime using the JavaScript API. This is useful for responsive layouts, user preferences, or A/B testing.

See Control & Methods for complete runtime configuration options and examples.

FAQ

Changing the script tag attributes after load has no effect. Use the runtime API (api.configure()) to change settings dynamically. See Control & Methods.

Yes, if you're using a templating language or build system:

<script
  data-client-key="<%= ENV['AGENT_CLIENT_KEY'] %>"
  data-agent-id="<%= ENV['AGENT_ID'] %>"
  ...
></script>

Add http://localhost:3000 (or your local port) to the allowed_domains when creating your client key. Use a development agent and client key separate from production.

Client keys are designed to be used in frontend code. They're restricted to specific domains you configure, so even if someone sees the key, they can't use it on their own site.