Traffic Sources
1 个变体An acquisition panel that shows where visitors come from by source, medium, or campaign, with favicons, share bars, and trend sparklines.
Source list
Where visitors come from by source, medium, or campaign over 7, 30, or 90 days, with real favicons, filled share bars, rolling counts, change deltas, and trend sparklines. Rows glide to their new rank when the period changes, and each row opens its bounce rate, conversion, and top landing pages.
Traffic sources
- 26,048up11%
- 15,243up9%
- 6,749up18%
- 5,900up38%
- 5,126up4%
- 3,765up7%
Top source google.com · 35% of visits · 12 sources
"use client";
import { TrafficSources } from "@/components/premium/traffic-sources";
export function TrafficSourcesListPreview() {
return (
<div className="w-full px-4 py-10">
<TrafficSources />
</div>
);
}
安装
API 参考
除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。
TrafficSources16 个属性
dataTotals and rows for every period and grouping.
TrafficSourcesDataperiodControlled period.
"7d" | "30d" | "90d"defaultPeriodPeriod when uncontrolled.
"7d" | "30d" | "90d"默认值
30donPeriodChangeCalled when a period is chosen.
((period: TrafficPeriod) => void)dimensionControlled grouping.
"source" | "medium" | "campaign"defaultDimensionGrouping when uncontrolled.
"source" | "medium" | "campaign"默认值
sourceonDimensionChangeCalled when a grouping is chosen.
((dimension: TrafficDimension) => void)maxRowsMost rows in the list.
number默认值
6periodLabelsPeriod tab labels; any period left out keeps its default.
Partial<Record<TrafficPeriod, string>>barClassNamesFilled share bar class for each grouping; any left out keeps its default.
Partial<Record<TrafficDimension, string>>strokeClassNamesSparkline stroke class for each grouping; any left out keeps its default.
Partial<Record<TrafficDimension, string>>formatNumberFormats visitor counts in the detail strip.
((value: number) => string)formatPercentFormats rates and shares, given as 0 to 1.
((value: number) => string)formatFooterBuilds the footer line from the top row, its share and the row count.
((info: TrafficFooterInfo) => string)labelsCopy overrides; anything left out uses the English defaults.
Partial<TrafficSourcesLabels>classNameClasses merged onto the root element.
string
ChangeDelta4 个属性
from必填Value in the previous period.
numberto必填Value in the selected period.
numbervariant`pill` draws a tinted pill for the header; `inline` draws small colored text for rows.
"inline" | "pill"默认值
inlineclassNameClasses merged onto the root element.
string
SourceDetail7 个属性
id必填Element id, referenced by the row toggle's `aria-controls`.
stringpages必填Top landing pages for the row.
TrafficLandingPage[]total必填Row visitors, used for each page's share.
numberheading必填Heading above the pages.
stringreduce必填Skip movement, keep fades.
booleanformatNumber必填Formats visitor counts.
(value: number) => stringformatPercent必填Formats each page's share of the row.
(value: number) => string
SourceFavicon4 个属性
domainSite domain to load the favicon for.
stringiconFallback icon when there is no domain or the favicon fails.
"search" | "email" | "paid" | "campaign" | "direct" | "social" | "referral"label必填Row label, used for the initial when there is no icon either.
stringclassNameClasses merged onto the root element.
string
SourceList13 个属性
rows必填Rows for the selected period and grouping.
TrafficSourceRow[]total必填All visitors in the period, for each row's share of visits.
numberperiod必填Selected period; a change redraws the sparklines.
"7d" | "30d" | "90d"dimension必填Selected grouping.
"source" | "medium" | "campaign"dimensions必填Groupings offered, in display order.
TrafficDimension[]onDimensionChange必填Called when a grouping tab is chosen.
(dimension: TrafficDimension) => voidmaxRows必填Most rows shown at once.
numberreduce必填Skip movement, keep fades.
booleanlabels必填Copy for tabs, headings, tooltip and the empty state.
TrafficSourcesLabelsbarClassNames必填Filled share bar class for each grouping.
Record<TrafficDimension, string>strokeClassNames必填Sparkline stroke class for each grouping.
Record<TrafficDimension, string>formatNumber必填Formats visitor counts in the detail strip.
(value: number) => stringformatPercent必填Formats rates and shares.
(value: number) => string
SourceRow14 个属性
row必填The row to draw.
TrafficSourceRowshare必填Bar width as a share of the largest row, 0 to 1.
numbervisitShare必填The row's share of all visitors in the period, 0 to 1, shown in the tooltip.
numbertrendKey必填Changes when the period changes, so the sparkline draws in again.
stringdelay必填Entrance delay in seconds; 0 for rows that join after the list opens.
numberreduce必填Skip movement, keep fades.
booleanexpanded必填True while the landing pages strip is open.
booleanonToggle必填Called when the row is clicked or activated by keyboard.
() => voidbarClassName必填Filled share bar class, such as `bg-sky-500/15`.
stringstrokeClassName必填Sparkline stroke class, such as `stroke-sky-500`.
stringlabels必填Copy for the tooltip, toggle hint and detail heading.
TrafficSourcesLabelsformatNumber必填Formats visitor counts in the detail strip.
(value: number) => stringformatPercent必填Formats rates in the tooltip.
(value: number) => stringrefThe row element, so AnimatePresence can pop exiting rows out of the flow.
Ref<HTMLLIElement>
TrafficHeader6 个属性
total必填Totals for the selected period.
TrafficPeriodTotalperiod必填Selected period.
"7d" | "30d" | "90d"periods必填Periods offered, in display order.
TrafficPeriod[]periodLabels必填Tab label for each period.
Record<TrafficPeriod, string>onPeriodChange必填Called when a period is chosen.
(period: TrafficPeriod) => voidlabels必填Copy for the title, noun and change caption.
TrafficSourcesLabels
类型5 个类型
这些属性使用的对象类型及其字段。
TrafficFooterInfo4 个字段
dimension必填Selected grouping.
TrafficDimensiontopThe largest row, or undefined when the list is empty.
TrafficSourceRowshare必填Top row's share of all visitors in the period, 0 to 1.
numbercount必填Number of rows in the selected grouping.
number
TrafficSourcesLabels15 个字段
title必填Card heading.
stringvisitors必填Noun after the total.
stringdelta必填Text after the change pill beside the total.
stringperiods必填Accessible name for the period tabs.
stringdimensions必填Accessible name for the grouping tabs.
stringsource必填Source tab label.
stringmedium必填Medium tab label.
stringcampaign必填Campaign tab label.
stringcount必填Right column heading in the list.
stringbounce必填Bounce rate label in the row tooltip.
stringconversion必填Conversion label in the row tooltip.
stringshare必填Share of visits label in the row tooltip.
stringlanding必填Heading of the expanded landing pages strip.
stringexpand必填Accessible hint on each row's toggle.
stringempty必填Shown when the selected grouping has no rows.
string
TrafficSourceRow10 个字段
id必填Stable id, used as the row key so rows glide between periods.
stringlabel必填Domain, channel or campaign name shown in the row.
stringdomainSite domain; when set, the row shows that site's favicon.
stringiconFallback icon when there is no domain or the favicon fails to load.
TrafficSourceIconvisitors必填Visitors in the selected period.
numberprevious必填Visitors in the period before it, for the change figure.
numberbounceRate必填Share of visits that left after one page, 0 to 1.
numberconversionRate必填Share of visits that converted, 0 to 1.
numbertrend必填Visitors per day (or per bucket) across the period, oldest first.
number[]landingPagesTop landing pages for this row, shown when the row is expanded.
TrafficLandingPage[]
TrafficLandingPage2 个字段
path必填Page path, such as `/pricing`.
stringvisitors必填Visitors from this row who landed on the page.
number
TrafficPeriodTotal2 个字段
visitors必填All visitors in the period.
numberprevious必填All visitors in the period before it.
number