Back to Prompt Library
App Building
Conversion Intelligence System
Add a complete Conversion Intelligence system — track user behavior, analyze funnels, get specific AI recommendations tied to your products and services, and turn analytics into action.
The prompt
You are a senior full-stack engineer and CRO (Conversion Rate Optimization) analyst building inside a Base44 app.
Your task is to add a complete Conversion Intelligence System — additively, without breaking any existing pages, routes, entities, or business logic.
GOAL: Give the admin a clear way to track what users actually do, see which pages/CTAs work, analyze funnels and drop-off, get AI-generated recommendations that are specific, business-aware, and actionable, and track which recommendations have been implemented.
PART 1 — DATA MODEL (all admin-only via RLS except where noted):
1. UserEvent (anyone create; admins read/update/delete) — user_id, session_id, anonymous_id, event_type (page_view, button_click, cta_click, form_start, form_submit, checkout_start, purchase, lead_created, service_view, product_view, pricing_view, blog_view, scroll_depth, time_on_page, exit_intent, search, download, video_play, external_link_click), event_name, page_url/path/title/type, referrer, device_type, browser, OS, country/state/city, utm_*, metadata.
2. UserSession (anyone create/update; admins read/delete) — user_id, anonymous_id, session_id, first/last page, referrer, traffic_source, utm_*, device/browser/OS/location, started_at, ended_at, duration_seconds, page_count, event_count, converted, conversion_type, conversion_value.
3. PagePerformance (admin-only) — page_url/path/title/type, total_views, unique_visitors, avg_time_on_page, bounce_rate, exit_rate, scroll_25/50/75/100, cta_clicks, form_starts, form_submits, conversion_count, conversion_rate, revenue_attributed, lead_count, last_updated.
4. ConversionGoal (admin-only) — name, description, goal_type, target_page_url, target_event_name, target_event_type, value, active.
5. FunnelDefinition (admin-only) — name, description, steps (array of {label, match_type, value}; match_type: page_path, page_path_prefix, event_type, event_name), active.
6. CISettings (admin-only, singleton) — important_pages, ignored_pages, primary_cta_labels, tracked_products, tracked_services, recommendation_frequency (weekly/biweekly/monthly/manual), notify_email, notify_on_urgent.
7. CIRecommendation (admin-only) — title, summary, category, priority (urgent/high/medium/low), impact_estimate, effort_estimate, target_page_path, target_funnel_id, evidence (array of real metrics), suggested_actions (array), status (new/acknowledged/in_progress/implemented/dismissed), admin_notes, analysis_window_days, generation_batch_id, model_used.
PART 2 — CLIENT-SIDE TRACKING LIBRARY: Small, fault-tolerant: persistent anonymous_id (localStorage), per-visit session_id (sessionStorage with idle timeout), page_view on route change, cta_click on [data-cta] / primary CTA labels (configurable), form_start (first focus) + form_submit, scroll_depth at 25/50/75/100% (sampled), time_on_page on unload (sampled), capture device/browser/OS/referrer/UTM. Sample high-frequency events. Wrap all sends in try/catch — analytics must NEVER break the app. Mount globally via App.jsx. EXCLUDE admin and CRM paths.
PART 3 — BACKEND FUNCTIONS (admin-only; verify role or x-base44-automation header): trackConversionEvent (public ingest creating UserEvent + updating UserSession), getConversionOverview(days), getPagePerformance(days), getPageDetail(path, days), getFunnelAnalysis(funnel_id, days), generateConversionRecommendations(days), updateRecommendationStatus(id, status, admin_notes).
PART 4 — ADMIN DASHBOARD at /admin/conversion-intelligence: Overview (time range 7/30/90d, KPI cards for Visitors/Sessions/Page Views/CTA Clicks/Form Submits/Conversion Rate, subnav cards, top sources/pages/CTAs, refresh); Page Performance (sortable table, filter by type, search, detail drawer with scroll depth/top CTAs/referrers/devices/UTM/event breakdown); Funnels (builder UI, step types, drop-off visualization, biggest drop-off callout); Conversion Goals (CRUD form, active/paused toggle, value field); AI Recommendations (Generate button, filters by status/priority/category, list with badges + target page + summary, detail drawer with full evidence + suggested actions + status changer + notes, empty/loading/error states); Settings (important/ignored pages, CTA labels, tracked products/services, recommendation frequency, notify email + urgent toggle).
PART 5 — AI RECOMMENDATIONS (critical): Recommendations must be SPECIFIC (tied to a real page/CTA/funnel/product/service), EVIDENCE-BASED (every claim backed by an actual metric), BUSINESS-AWARE (references products/services sold), and ACTIONABLE. For each: exact page/area affected, behavior that triggered it, likely conversion problem, suggested fix, why it should help (CRO principle), product/service it supports, priority, estimated impact, next action. Deduplicate/merge before saving; cap at 7 high-quality recommendations per run. Pass the LLM the top 25 pages with metrics, funnel summaries, active goals, tracked products/services, and important/ignored pages. Use a strict JSON response schema. If any recommendation is urgent AND notify_on_urgent is true AND notify_email is set, send an email summary with a link to the recommendations page.
PART 6 — SCHEDULED ANALYSIS: Create an automation "Weekly Conversion Intelligence Analysis" every Monday 7:00 AM (admin timezone) running generateConversionRecommendations with days=7; the function must accept being triggered without an authenticated user (check the automation header).
PART 7 — DASHBOARD UX RULES: Match the existing admin design system exactly; WCAG AA contrast; never block the UI on slow queries (loading states, graceful fallback); guiding empty states; compact, sortable, filterable tables; detail drawers on row click; tabular numerals for metrics; recommendations sorted by priority (urgent → low).
PART 8 — SAFETY (critical): Never modify existing entities/pages/routes/business logic; never expose tracked data outside the admin role; never log PII (email, full IPs); sample and rate-limit tracking; all analytics failures must be silent; backend functions verify admin role on every call (or accept the automation header).
DELIVERABLES: Summary of every entity/function/page/automation created; how to test the tracking client; how to seed the first funnel and goal; how to manually trigger the recommendation engine; any limitations or follow-up phases. Build the complete system now.App Building
#analytics
#conversion
#funnels
#ai
