root = Card([header, kpiRow, dateRangeForm, visitorsSection, sourcesSection, campaignsSection, subscribersSection, exportBtn])
header = CardHeader("Marketing Weekly Dashboard", "Week of April 21–27, 2026 · Auto-refreshed 06:00 UTC")
kpiRow = SnippetCardBlock([kpiVisitors, kpiConv, kpiRevenue, kpiSubs], "grid", true)
kpiVisitors = SnippetCardItem("visitors", kpiVisLhs, kpiVisRhs)
kpiVisLhs = IconText(kpiVisIcon, "neutral", "m", "Site Visitors", "Last 30 days", false, "horizontal")
kpiVisIcon = Icon("users", "people")
kpiVisRhs = BoldText("number", "142.3K", "+8.2%", "metric")
kpiConv = SnippetCardItem("conversion", kpiConvLhs, kpiConvRhs)
kpiConvLhs = IconText(kpiConvIcon, "neutral", "m", "Conversion Rate", "All channels", false, "horizontal")
kpiConvIcon = Icon("target", "charts")
kpiConvRhs = BoldText("number", "3.47%", "+0.31%", "metric")
kpiRevenue = SnippetCardItem("revenue", kpiRevLhs, kpiRevRhs)
kpiRevLhs = IconText(kpiRevIcon, "neutral", "m", "Attributed Revenue", "Last 30 days", false, "horizontal")
kpiRevIcon = Icon("circle-dollar-sign", "finance")
kpiRevRhs = BoldText("number", "$487.2K", "+12.4%", "metric")
kpiSubs = SnippetCardItem("subscribers", kpiSubsLhs, kpiSubsRhs)
kpiSubsLhs = IconText(kpiSubsIcon, "neutral", "m", "Email Subscribers", "Net growth this month", false, "horizontal")
kpiSubsIcon = Icon("mail", "communication")
kpiSubsRhs = BoldText("number", "+2,847", "+14.6%", "metric")
dateRangeForm = Form("date-range", dateBtns, [fcDateRange])
dateBtns = Buttons([btnApply, btnPreset], "row")
btnApply = Button("Apply Range", { type: "continue_conversation", context: "Update dashboard with selected date range" }, "primary")
btnPreset = Button("Last 7 Days", { type: "continue_conversation", context: "Set date range to last 7 days" }, "secondary")
fcDateRange = FormControl("Date Range", datePicker, "Select custom range or use presets")
datePicker = DatePicker("date-range", "range", { required: true })
visitorsSection = SectionBlock([secVisitors], false)
secVisitors = SectionItem("visitors", "Site Visitors — Last 30 Days", [visitorsChart, visitorsInsight])
visitorsChart = LineChart(visLabels, [visSeries], "natural", "Date", "Visitors")
visLabels = ["Mar 29", "Mar 30", "Mar 31", "Apr 1", "Apr 2", "Apr 3", "Apr 4", "Apr 5", "Apr 6", "Apr 7", "Apr 8", "Apr 9", "Apr 10", "Apr 11", "Apr 12", "Apr 13", "Apr 14", "Apr 15", "Apr 16", "Apr 17", "Apr 18", "Apr 19", "Apr 20", "Apr 21", "Apr 22", "Apr 23", "Apr 24", "Apr 25", "Apr 26", "Apr 27", "Apr 28"]
visSeries = Series("Daily Visitors", [4120, 3980, 4050, 4210, 4380, 4520, 4680, 4410, 4290, 4560, 4720, 4890, 5010, 4850, 4720, 4980, 5150, 5280, 5420, 5180, 5050, 5310, 5480, 5620, 5780, 5540, 5410, 5680, 5820, 5950])
visitorsInsight = TextContent("**Peak:** Apr 28 (5,950) · **Low:** Mar 30 (3,980) · Weekend dip visible Apr 4–5 & Apr 11–12. Trend: +8.2% vs prior 30 days.")
sourcesSection = SectionBlock([secSources], false)
secSources = SectionItem("sources", "Top 5 Traffic Sources — Share of Sessions", [sourcesChart, sourcesTable])
sourcesChart = HorizontalBarChart(srcLabels, [srcSeries], "grouped", "Sessions (%)", "Source")
srcLabels = ["Organic Search", "Paid Search", "Direct", "Email", "Referral"]
srcSeries = Series("Share %", [42.3, 24.1, 18.7, 9.8, 5.1])
sourcesTable = Table([colSrc, colSessions, colShare, colConv, colRevenue])
colSrc = Col("Source", ["Organic Search", "Paid Search", "Direct", "Email", "Referral"], "string")
colSessions = Col("Sessions", [60180, 34290, 26610, 13940, 7250], "number")
colShare = Col("Share", ["42.3%", "24.1%", "18.7%", "9.8%", "5.1%"], "string")
colConv = Col("Conv. Rate", ["4.12%", "2.87%", "3.05%", "5.41%", "2.34%"], "string")
colRevenue = Col("Revenue", ["$204.8K", "$98.4K", "$81.2K", "$75.6K", "$27.2K"], "string")
campaignsSection = SectionBlock([secCampaigns, secBest], false)
secCampaigns = SectionItem("campaigns", "Running Campaigns — Spend & Performance", [campaignsTable])
campaignsTable = Table([colCamp, colSpend, colImpr, colClicks, colCtr, colCpc, colConv, colRoas, colStatus])
colCamp = Col("Campaign", ["Spring Sale 2026", "New Arrivals Push", "Brand Awareness Q2", "Retargeting Cart", "Influencer Collab", "Email Welcome Flow"], "string")
colSpend = Col("Spend", [18450, 12800, 8200, 4650, 3100, 1200], "number")
colImpr = Col("Impressions", [842000, 567000, 1240000, 189000, 234000, 45000], "number")
colClicks = Col("Clicks", [12640, 8500, 6200, 3400, 2100, 1850], "number")
colCtr = Col("CTR", ["1.50%", "1.50%", "0.50%", "1.80%", "0.90%", "4.11%"], "string")
colCpc = Col("CPC", ["$1.46", "$1.51", "$1.32", "$1.37", "$1.48", "$0.65"], "string")
colConv = Col("Conversions", [487, 298, 156, 142, 68, 89], "number")
colRoas = Col("ROAS", ["4.2x", "3.8x", "2.9x", "5.1x", "3.4x", "6.8x"], "string")
colStatus = Col("Status", ["Active", "Active", "Active", "Active", "Paused", "Active"], "string")
secBest = SectionItem("best", "🏆 Best Performing Campaign", [bestCard])
bestCard = CompositeCardBlock([bestItem], "grid", true)
bestItem = CompositeCardItem("best-campaign", bestHeader, [bestMetric, bestChart, bestDetails], { price: bestPrice })
bestHeader = IconText(bestIcon, "success", "m", "Retargeting Cart Abandoners", "Highest ROAS · 5.1x return on ad spend", true, "horizontal")
bestIcon = Icon("target", "charts")
bestMetric = MetricIndicatorInline("5.1x ROAS", "Return on Ad Spend", { direction: "up", value: 0.7 })
bestChart = BarChart(bestLabels, [bestSpend, bestRev], "grouped", "Week", "Value ($)")
bestLabels = ["Wk 1", "Wk 2", "Wk 3", "Wk 4"]
bestSpend = Series("Spend", [980, 1050, 1120, 1500])
bestRev = Series("Revenue", [4850, 5200, 5680, 7650])
bestDetails = EntityList([bd1, bd2, bd3, bd4], "small")
bd1 = { left: "Total Spend", right: "$4,650", rightVariant: "number" }
bd2 = { left: "Conversions", right: "142", rightVariant: "number" }
bd3 = { left: "Avg. Order Value", right: "$168", rightVariant: "number" }
bd4 = { left: "Audience Size", right: "12,400 users", rightVariant: "text" }
bestPrice = MetricIndicatorWithStrikethrough("$23,800", "Attributed Revenue", "$18,200", { direction: "up", value: 30.8 })
subscribersSection = SectionBlock([secSubs], false)
secSubs = SectionItem("subs", "Email Subscriber Growth — April 2026", [subsChart, subsInsight])
subsChart = AreaChart(subLabels, [subsNet, subsGross], "natural", "Date", "Subscribers")
subLabels = ["Apr 1", "Apr 3", "Apr 5", "Apr 7", "Apr 9", "Apr 11", "Apr 13", "Apr 15", "Apr 17", "Apr 19", "Apr 21", "Apr 23", "Apr 25", "Apr 27"]
subsNet = Series("Net Growth", [120, 245, 380, 510, 680, 820, 980, 1150, 1340, 1520, 1710, 1950, 2240, 2847])
subsGross = Series("Gross Adds", [180, 350, 540, 720, 940, 1120, 1320, 1540, 1780, 2010, 2250, 2540, 2880, 3420])
subsInsight = TextContent("**Net +2,847** this month (14.6% growth). Gross adds 3,420 · unsubscribes 573 (1.2% churn). Welcome flow converts at 4.1% → first purchase.")
exportBtn = Buttons([btnExport], "row")
btnExport = Button("Export Full Report (PDF)", { type: "continue_conversation", context: "Export the current dashboard view as a PDF report with all charts and tables" }, "primary", "normal", "medium")