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 リファレンス
必須と記された props 以外はすべて省略できます。データ、文言、色はサンプルの内容が既定値です。
TrafficSources16 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の型
これらの props が受け取るオブジェクト型とそのフィールド。
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