Embedded Analytics
Embedded analytics are analytics and visualizations built into a product, visible to end users. Not internal analytics for your team, but features that show users the value your product creates.
Why Embedded Analytics Matter
Showing users their data increases engagement and retention. A user who sees the value your product creates is less likely to churn.
Example: a project management tool shows users time spent on tasks, productivity metrics. Users see they're using the tool well, they're more likely to keep paying.
The Value Proposition
Users want to understand their usage and impact. "Here's how much time you saved." "Your team's productivity increased 15%." Demonstrating value is powerful.
Building vs Buying for Embedded Analytics
Build: full control, native feel, significant development. Building a full analytics UI from scratch is weeks of work.
Buy: faster time to market, less control, cost. Services like Metabase Embedding, Grafana Embedding, Cube.js provide embeddable analytics.
Multi-Tenant Embedded Analytics
Each customer sees only their own data. Customer A can't see Customer B's metrics. Tenant isolation is critical.
The analytics query layer must enforce tenant boundaries. Before executing a query, verify the authenticated user's tenant. Only return that tenant's data.
White-Labeling Requirements
Embedded analytics must look like your product, not a third-party tool. Matching colors, fonts, branding. The user shouldn't think "oh, this is Metabase embedded in their app."
If buying a solution, it must support customization. Metabase has theming. Cube.js is customizable. Ensure you can white-label.
Data Access Layer
You need an API that serves analytics queries. The client-side analytics UI calls this API. The API enforces: authentication, authorization, tenant isolation, query validation.
Never expose raw database access to the client. Always go through your API. The API can enforce permissions and limits.
Row-Level Security at the Query Level
The API querying the database must enforce tenant isolation. An embedded analytics query for tenant A must only return tenant A's data.
Don't rely on front-end filtering. If the front-end filters by tenant_id but the API ignores it, data leaks. The API must enforce isolation.
Performance Challenges
Analytics queries are expensive. A query aggregating a year of data across all customers takes time. In embedded contexts, users expect fast feedback.
Caching is more important. Cache query results for some time. If a user asks the same question twice in 5 minutes, return the cached result.
Limiting Query Scope
Users can craft slow queries. Limit date ranges ("can only view last 2 years"), limit complexity (no more than 3 dimensions), timeout queries.
This prevents users from accidentally (or intentionally) running expensive queries.
Metrics and Dimensions
Define what's available for analytics. Metrics: revenue, user count, time spent. Dimensions: product, region, date.
Don't expose all raw data. Curate what users can see. This simplifies the UI and protects sensitive data.
Examples: When to Use Embedded Analytics
SaaS with usage-based pricing: show usage metrics so customers understand charges.
Marketing platform: show campaign performance to users.
Analytics tools themselves: obviously. But also any product with user-generated data that benefits from visualization.
| Approach | Build In-House | Buy/Embed (Metabase, Cube) |
|---|---|---|
| Time to market | Weeks to months | Days to weeks |
| Control | Complete | Limited by platform |
| Customization | Unlimited | Platform-dependent |
| Cost (dev) | High | Low |
| Cost (runtime) | Infrastructure | SaaS fees |
| Maintenance | Your team | Vendor |
| Scalability | Your responsibility | Vendor handles |
| Data security | Your responsibility | Shared responsibility |