Early bird: 30% off Dashral ProSee pricing

Dashral

Analytics overviewPro

A whole analytics page: who's online, numbers that pick what the chart shows, the period before, and pages, sources and countries.

Installation

When to use

  • A whole analytics page: who's online, numbers that pick what the chart shows, the period before, and top lists.
  • Product and marketing analytics with a few headline metrics and a 7, 30 or 90 day range.

When not to use

  • Ops and infrastructure metrics across many small panels: Analytics panels.
  • One or two numbers on a home page: Stats cards.

Usage

Analytics overview with your own data: every prop has the sample as its default, so pass only what you have.

example.tsx
"use client"

import { useState } from "react"
import { AnalyticsOverview } from "@/components/dashral/blocks/analytics-overview"

export default function Analytics() {
  const [site, setSite] = useState("acme.com")
  const [period, setPeriod] = useState("7d")

  return (
    <AnalyticsOverview
      sites={["acme.com", "docs.acme.com"]}
      site={site}
      onSiteChange={setSite}
      online={18}
      metrics={[
        { id: "visitors", label: "Visitors" },
        { id: "bounce", label: "Bounce rate", format: (value) => `${value}%`, aggregate: "average", invert: true },
      ]}
      periods={[
        {
          value: "7d",
          label: "Last 7 days",
          compare: "vs. the week before",
          labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          series: {
            visitors: { now: [820, 940, 910, 1_020, 980, 640, 590], before: [760, 810, 870, 900, 950, 600, 560] },
            bounce: { now: [41, 39, 40, 38, 37, 44, 45], before: [43, 42, 41, 40, 40, 46, 47] },
          },
          pages: [{ label: "/", value: 2_410 }, { label: "/pricing", value: 980 }],
          sources: [{ label: "Google", value: 3_120 }, { label: "Direct", value: 1_460 }],
          countries: [{ label: "Indonesia", value: 2_050 }, { label: "Germany", value: 940 }],
        },
      ]}
      period={period}
      onPeriodChange={setPeriod}
      onExport={(period) => console.log("export", site, period)}
    />
  )
}

API reference

AnalyticsOverview

A whole analytics page: the site, who's online, a period switch and export; four numbers that each pick what the chart shows, with their change; an area chart against the period before, read by hover or the arrow keys; then top pages, sources and countries. Every part follows the period. Your sites, metrics and each period's figures come from props; with period and onPeriodChange you load a period's figures as it's picked.

PropTypeDefault
sitesstring[]sample
sitestring

The site shown (the page keeps it without it).

—
onSiteChange(site: string) => void—
onlinenumber | null

People on the site right now; null hides it.

38
metricsAnalyticsMetric[]sample
periodsAnalyticsPeriod[]sample
periodstring—
onPeriodChange(period: string) => void—
onExport(period: string) => void—

type AnalyticsMetric

A number on top: how it reads, and how a period's values add up to it ("sum", or "average" for rates).

PropTypeDefault
idstring—
labelstring—
format(value: number) => string—
aggregate"sum" | "average"—
invertboolean—

type BreakdownItem

PropTypeDefault
labelstring—
valuenumber—

type AnalyticsPeriod

A period on the switch: the chart's labels, what it compares with, each metric's values now and before (by id), and the breakdowns.

PropTypeDefault
valuestring—
labelstring—
comparestring—
labelsstring[]—
seriesRecord<string, { now: number[]; before: number[] }>—
pagesBreakdownItem[]—
sourcesBreakdownItem[]—
countriesBreakdownItem[]—