How we collect data
Transparency on source APIs, permissions, approval gates, and provider limits.
High level
Mercidia connects to configured commerce, analytics, and advertising sources through their official APIs. Launch connections are read-oriented and request only the permissions needed to load source records. Pilot is separate: it is available only for explicitly approved rules and supported provider actions; unavailable or unsupported actions fail closed.
What we read
- Orders, refunds, products, and related revenue fields from Shopify.
- Events, sessions, and conversion reporting from GA4 when the service account has property access.
- Campaign and performance records from Meta Ads using the read-only ads_read permission.
- Google Ads remains an evaluation connector and is not part of the launch-ready source claim.
What Pilot can do
- Evaluate approved rules against available source data and record a proposed, pending, skipped, or completed result.
- Run a supported provider action only after approval, role, budget, and rollback checks pass.
- Keep unsupported or unavailable provider actions unapplied and visible for review.
Meta Ads currently uses ads_read and is read-only; it cannot pause or enable campaigns or change budgets or bids through this connection. Pilot behavior also depends on provider support and account authorization.
Technical details — how data is retrieved
Key points below map directly to the codebase so you can follow the exact technical process.
- API fetching layer: The frontend uses
fetchJsoninfrontend/src/lib/api.tsto call backend endpoints. On the server it calls the real API base URL (viagetApiBaseUrl()) and attaches an API key when available. In the browser it proxies calls to/api/proxy. - Endpoints and unavailable states: Dashboard data is loaded by
loadDashboardData()from workspace-scoped/recommendationsand/connectorsendpoints. Network or connector failures produce empty or unavailable states; they are not replaced with fabricated records. - Connector syncs: The launch paths include Shopify, Meta Ads, and GA4, with diagnostics and sync endpoints invoked through server-backed
fetchJsonwrappers. Google Ads route coverage remains evaluation-only until hosted lifecycle validation is complete. - Automation actions: The automation system reads persisted rules, campaign metrics, and action records from the backend. A run records the provider result when one exists, approval state, daily-cap decision, and audit event; unavailable or unsupported platform data does not become an applied action.
Technical details — how metrics are derived
Metric calculations are implemented server-side helper functions that the frontend consumes. The key functions are in frontend/src/lib/dashboard.ts and frontend/src/lib/businessConfigMetrics.ts. Highlights:
- Recommendation-based dashboard metrics:
calculateDashboardMetrics(recommendations)reduces recommendation records to totals (cost, revenue, impact). It builds channel-level aggregates and derives:totalSpend— sum of recommendation.metrics.costtotalRevenue— sum of recommendation.metrics.revenueoverallRoi— (revenue - spend) / spendmarketingEfficiency— revenue / spendpotentialSavings— totals.impact (sum of recommended savings)
- Paid media blend: Available campaign sources are aggregated by spend, revenue, impressions, clicks, and conversions, then used to compute derived metrics such as
roi,ctr, andcpa. Email remains preview-only rather than a live sync source, and Google Ads values remain evaluation data until hosted validation is complete. - Business-config derived metrics: Independent of connectors,
deriveBusinessMetrics(config)(inbusinessConfigMetrics.ts) uses the business setup inputs like currentMonthlyRevenue and totalMarketingBudgetMonthly to compute:netProfit— revenue - total monthly costs (including marketing and fixed/operational costs)profitPerDollar— netProfit / marketingSpendmarketingEfficiency— revenue / marketingSpend * 100- Break-even orders, gross/net margin per order, and spend share
- Attribution: Frontend fetches an attribution summary via
fetchAttributionSummary()inapi.ts. The attribution breakdown compares first-touch, last-touch, and linear allocations over recorded journeys, with the lookback window and evidence limits shown beside the result. On failure, the frontend uses an empty summary state.
Privacy & security
We store the data needed to provide reconciliation, source health, decision records, and approved workflows. Connector credentials are encrypted at rest and accessed server-side through scoped connector paths. Read our full Privacy Policy for details.