iFrame
Learn how to use the iframe to embed the self-service analytics experience in your app.
Overview
Zero-Dependency Embeds with iFrame
When you embed Semaphor using an iFrame, you don’t need to bundle any analytics libraries, UI components, or dependencies into your application. Everything: visualization libraries, state management, styling, and interactive features lives fully within the Semaphor frame.
This gives you two major advantages:
-
No extra dependencies in your codebase Your app stays lightweight. You’re not shipping chart libraries, SDKs, or custom components just to display analytics. Semaphor handles all of that inside the frame.
-
Analytics stays isolated from your product code There’s no risk of CSS collisions, version conflicts, or package bloat. Semaphor runs in its own sandbox, so your product and your analytics never step on each other.
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
tokenExpiryin your token request to control session duration.