iFrame
Learn how to use the iframe to embed the self-service analytics experience in your app.
This section outlines step-by-step instructions for embedding the Semaphor self-service analytics experience in your app using an iframe.
1. Obtain the Auth Token
Before rendering an iframe, you need to retrieve an Auth Token. This token ensures secure access to your embed session.
Do not expose projectSecret
in client-side code in production. Use a backend
service to fetch the token securely.
2. Build the Embed URL
Use the token to generate the iframe URL. You can control the experience with query parameters.
3. Render the Iframe
Render the iframe inside a responsive container.
URL Parameters
- showAssistant: Enable the AI assistant panel in the embed (true/false)
- showControls: Show header controls for the embed (true/false)
- currentTheme: Set theme for the embed (
light
,dark
, orsystem
)
Append these as query parameters to the embed URL as needed.
Key Considerations
- Security: Always generate tokens server-side; never expose secrets in client code.
- Sizing: Wrap the iframe in a container with explicit width/height for proper layout.
- Token expiry: Use
tokenExpiry
in your token request to control session duration.