Traffic Sources
1 variantAn 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>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
API Reference
Every prop is optional unless marked required. Data, copy, and colors default to the sample content.
TrafficSources16 props
dataTotals and rows for every period and grouping.
TrafficSourcesDataperiodControlled period.
"7d" | "30d" | "90d"defaultPeriodPeriod when uncontrolled.
"7d" | "30d" | "90d"Default
30donPeriodChangeCalled when a period is chosen.
((period: TrafficPeriod) => void)dimensionControlled grouping.
"source" | "medium" | "campaign"defaultDimensionGrouping when uncontrolled.
"source" | "medium" | "campaign"Default
sourceonDimensionChangeCalled when a grouping is chosen.
((dimension: TrafficDimension) => void)maxRowsMost rows in the list.
numberDefault
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
fromRequiredValue in the previous period.
numbertoRequiredValue in the selected period.
numbervariant`pill` draws a tinted pill for the header; `inline` draws small colored text for rows.
"inline" | "pill"Default
inlineclassNameClasses merged onto the root element.
string
SourceDetail7 props
idRequiredElement id, referenced by the row toggle's `aria-controls`.
stringpagesRequiredTop landing pages for the row.
TrafficLandingPage[]totalRequiredRow visitors, used for each page's share.
numberheadingRequiredHeading above the pages.
stringreduceRequiredSkip movement, keep fades.
booleanformatNumberRequiredFormats visitor counts.
(value: number) => stringformatPercentRequiredFormats 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"labelRequiredRow label, used for the initial when there is no icon either.
stringclassNameClasses merged onto the root element.
string
SourceList13 props
rowsRequiredRows for the selected period and grouping.
TrafficSourceRow[]totalRequiredAll visitors in the period, for each row's share of visits.
numberperiodRequiredSelected period; a change redraws the sparklines.
"7d" | "30d" | "90d"dimensionRequiredSelected grouping.
"source" | "medium" | "campaign"dimensionsRequiredGroupings offered, in display order.
TrafficDimension[]onDimensionChangeRequiredCalled when a grouping tab is chosen.
(dimension: TrafficDimension) => voidmaxRowsRequiredMost rows shown at once.
numberreduceRequiredSkip movement, keep fades.
booleanlabelsRequiredCopy for tabs, headings, tooltip and the empty state.
TrafficSourcesLabelsbarClassNamesRequiredFilled share bar class for each grouping.
Record<TrafficDimension, string>strokeClassNamesRequiredSparkline stroke class for each grouping.
Record<TrafficDimension, string>formatNumberRequiredFormats visitor counts in the detail strip.
(value: number) => stringformatPercentRequiredFormats rates and shares.
(value: number) => string
SourceRow14 props
rowRequiredThe row to draw.
TrafficSourceRowshareRequiredBar width as a share of the largest row, 0 to 1.
numbervisitShareRequiredThe row's share of all visitors in the period, 0 to 1, shown in the tooltip.
numbertrendKeyRequiredChanges when the period changes, so the sparkline draws in again.
stringdelayRequiredEntrance delay in seconds; 0 for rows that join after the list opens.
numberreduceRequiredSkip movement, keep fades.
booleanexpandedRequiredTrue while the landing pages strip is open.
booleanonToggleRequiredCalled when the row is clicked or activated by keyboard.
() => voidbarClassNameRequiredFilled share bar class, such as `bg-sky-500/15`.
stringstrokeClassNameRequiredSparkline stroke class, such as `stroke-sky-500`.
stringlabelsRequiredCopy for the tooltip, toggle hint and detail heading.
TrafficSourcesLabelsformatNumberRequiredFormats visitor counts in the detail strip.
(value: number) => stringformatPercentRequiredFormats rates in the tooltip.
(value: number) => stringrefThe row element, so AnimatePresence can pop exiting rows out of the flow.
Ref<HTMLLIElement>
TrafficHeader6 props
totalRequiredTotals for the selected period.
TrafficPeriodTotalperiodRequiredSelected period.
"7d" | "30d" | "90d"periodsRequiredPeriods offered, in display order.
TrafficPeriod[]periodLabelsRequiredTab label for each period.
Record<TrafficPeriod, string>onPeriodChangeRequiredCalled when a period is chosen.
(period: TrafficPeriod) => voidlabelsRequiredCopy for the title, noun and change caption.
TrafficSourcesLabels
Types5 types
The object types these props take, field by field.
TrafficFooterInfo4 fields
dimensionRequiredSelected grouping.
TrafficDimensiontopThe largest row, or undefined when the list is empty.
TrafficSourceRowshareRequiredTop row's share of all visitors in the period, 0 to 1.
numbercountRequiredNumber of rows in the selected grouping.
number
TrafficSourcesLabels15 fields
titleRequiredCard heading.
stringvisitorsRequiredNoun after the total.
stringdeltaRequiredText after the change pill beside the total.
stringperiodsRequiredAccessible name for the period tabs.
stringdimensionsRequiredAccessible name for the grouping tabs.
stringsourceRequiredSource tab label.
stringmediumRequiredMedium tab label.
stringcampaignRequiredCampaign tab label.
stringcountRequiredRight column heading in the list.
stringbounceRequiredBounce rate label in the row tooltip.
stringconversionRequiredConversion label in the row tooltip.
stringshareRequiredShare of visits label in the row tooltip.
stringlandingRequiredHeading of the expanded landing pages strip.
stringexpandRequiredAccessible hint on each row's toggle.
stringemptyRequiredShown when the selected grouping has no rows.
string
TrafficSourceRow10 fields
idRequiredStable id, used as the row key so rows glide between periods.
stringlabelRequiredDomain, 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.
TrafficSourceIconvisitorsRequiredVisitors in the selected period.
numberpreviousRequiredVisitors in the period before it, for the change figure.
numberbounceRateRequiredShare of visits that left after one page, 0 to 1.
numberconversionRateRequiredShare of visits that converted, 0 to 1.
numbertrendRequiredVisitors 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 fields
pathRequiredPage path, such as `/pricing`.
stringvisitorsRequiredVisitors from this row who landed on the page.
number
TrafficPeriodTotal2 fields
visitorsRequiredAll visitors in the period.
numberpreviousRequiredAll visitors in the period before it.
number