📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
feat: SEO Quadrant
Blue Mouse3f6f5e2190e6
diff --git a/web/app/pages/OpenStartup/index.tsx b/web/app/pages/OpenStartup/index.tsxindex 8a8451ffe..14019d0d4 100644--- a/web/app/pages/OpenStartup/index.tsx+++ b/web/app/pages/OpenStartup/index.tsx@@ -388,12 +388,6 @@ const getSettings = () => {},},},- // area: {- // linearGradient: true,- // },- // padding: {- // right: rotateXAxias && 35,- // },bindto: '#open-startup',}}diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsxindex 4c49f29a5..dafe3ccd7 100644--- a/web/app/pages/Project/View/Panels.tsx+++ b/web/app/pages/Project/View/Panels.tsx@@ -80,6 +80,8 @@ interface PanelContainerProps {icon?: React.ReactNodetype: stringhideHeader?: boolean+ tooltip?: React.ReactNode+ contentClassName?: stringtabs?: Array<| {id: string@@ -102,6 +104,8 @@ const PanelContainer = ({icon,type,hideHeader,+ tooltip,+ contentClassName,tabs,onTabChange,activeTabId,@@ -131,6 +135,9 @@ const PanelContainer = ({>{icon ? <span className='mr-1'>{icon}</span> : null}{name}+ {tooltip ? (+ <span className='ml-1.5 flex items-center'>{tooltip}</span>+ ) : null}</Text><div className='scrollbar-thin flex items-center gap-2.5 overflow-x-auto'>{tabs && onTabChange ? (@@ -197,7 +204,12 @@ const PanelContainer = ({</div></div>) : null}- <div className='relative flex h-[19.6rem] flex-col overflow-hidden'>+ <div+ className={+ contentClassName ||+ 'relative flex h-[19.6rem] flex-col overflow-hidden'+ }+ >{children}</div>{onDetailsClick ? (@@ -2501,6 +2513,7 @@ const MetadataKeyPanelMemo = memo(MetadataKeyPanel) as typeof MetadataKeyPanelconst MetadataPanelMemo = memo(MetadataPanel) as typeof MetadataPanelexport {+ PanelContainer,PanelMemo as Panel,CustomEventsMemo as CustomEvents,MetadataKeyPanelMemo as MetadataKeyPanel,diff --git a/web/app/pages/Project/tabs/SEO/SEOView.tsx b/web/app/pages/Project/tabs/SEO/SEOView.tsxindex 4d76e8942..3276c18fc 100644--- a/web/app/pages/Project/tabs/SEO/SEOView.tsx+++ b/web/app/pages/Project/tabs/SEO/SEOView.tsx@@ -1,14 +1,16 @@import {ArrowClockwiseIcon,EyeIcon,+ InfoIcon,LinkIcon,PlugIcon,RobotIcon,MagnifyingGlassIcon,MapPinIcon,+ TargetIcon,} from '@phosphor-icons/react'import type { ChartOptions } from 'billboard.js'-import { area, donut } from 'billboard.js'+import { area, donut, scatter } from 'billboard.js'import * as d3 from 'd3'import dayjs from 'dayjs'import isoWeek from 'dayjs/plugin/isoWeek'@@ -23,7 +25,7 @@ import React, {use,useState,} from 'react'-import { useTranslation } from 'react-i18next'+import { Trans, useTranslation } from 'react-i18next'import { Link, useLoaderData, useSearchParams } from 'react-router'dayjs.extend(isoWeek)@@ -37,7 +39,7 @@ import BillboardChart from '~/ui/BillboardChart'import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import { MainChart } from '~/pages/Project/View/components/MainChart'import Filters from '~/pages/Project/View/components/Filters'-import { Panel } from '~/pages/Project/View/Panels'+import { Panel, PanelContainer } from '~/pages/Project/View/Panels'import {useViewProjectContext,useRefreshTriggers,@@ -56,6 +58,7 @@ import Checkbox from '~/ui/Checkbox'import Dropdown from '~/ui/Dropdown'import Loader from '~/ui/Loader'import { Text } from '~/ui/Text'+import Tooltip from '~/ui/Tooltip'import { nFormatter } from '~/utils/generic'import countries from '~/utils/isoCountries'import { getSearchEngineReferrals, getAIReferrals } from '~/utils/referrers'@@ -252,18 +255,14 @@ const CompactReferralPanel = ({if (_isEmpty(data)) {return (<div className='overflow-hidden rounded-lg border border-gray-200 bg-white px-4 py-3 dark:border-slate-800/60 dark:bg-slate-900/25'>- <div className='flex items-center gap-2'>+ <div className='flex items-center gap-1 text-gray-900 dark:text-gray-50'>{icon}<Text size='sm' weight='semibold'>{title}</Text></div><div className='flex h-32 items-center justify-center'>- <Text- size='xs'- colour='inherit'- className='text-gray-400 dark:text-gray-500'- >+ <Text size='xs' colour='inherit'>{t('project.noParamData')}</Text></div>@@ -292,12 +291,7 @@ const CompactReferralPanel = ({<div className='min-w-0'>{rowMapper(entry)}</div>)}{isOther ? (- <Text- size='xs'- colour='inherit'- truncate- className='text-gray-500 italic dark:text-gray-400'- >+ <Text size='xs' colour='inherit' truncate>{entry.name}</Text>) : null}@@ -306,7 +300,7 @@ const CompactReferralPanel = ({<Textsize='xs'colour='inherit'- className='mr-1.5 hidden text-gray-500 group-hover:inline dark:text-gray-400'+ className='mr-1.5 hidden group-hover:inline'>({perc}%)</Text>@@ -321,7 +315,7 @@ const CompactReferralPanel = ({return (<div className='overflow-hidden rounded-lg border border-gray-200 bg-white px-4 py-3 dark:border-slate-800/60 dark:bg-slate-900/25'><div className='mb-2 flex items-center justify-between'>- <div className='flex items-center gap-2'>+ <div className='flex items-center gap-1 text-gray-900 dark:text-gray-50'>{icon}<Text size='sm' weight='semibold'>{title}@@ -531,7 +525,11 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {[data?.topPages],)- const topQueriesAsEntries: Entry[] = useMemo(+ const topQueriesAsEntries: (Entry & {+ impressions: number+ ctr: number+ position: number+ })[] = useMemo(() =>(data?.topQueries || []).map((q) =>@@ -634,7 +632,6 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {size: {height: 180,},- padding: { top: 0, bottom: 0, left: 0, right: 0 },}}, [brandedTraffic, t, theme])@@ -650,6 +647,122 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {const anyMetricActive = Object.values(activeMetrics).some(Boolean)+ const quadrantData = useMemo(() => {+ if (!topQueriesAsEntries.length) return null+ const positions = topQueriesAsEntries.map((q) => q.position)+ const ctrs = topQueriesAsEntries.map((q) => q.ctr)+ const impressions = topQueriesAsEntries.map((q) => q.impressions)+ const names = topQueriesAsEntries.map((q) => q.name)++ const maxImp = Math.max(...impressions) || 1+ const minImp = Math.min(...impressions) || 0++ return { positions, ctrs, impressions, names, maxImp, minImp }+ }, [topQueriesAsEntries])++ const quadrantChartOptions: ChartOptions = useMemo(() => {+ if (!quadrantData) return {}++ const { positions, ctrs, impressions, names, maxImp } = quadrantData+ const avgCtr = data?.summary?.ctr ?? 5+ const avgPos = data?.summary?.position ?? 10++ return {+ data: {+ x: 'x',+ columns: [+ ['x', ...positions],+ ['CTR', ...ctrs],+ ],+ type: scatter(),+ colors: {+ CTR: theme === 'dark' ? '#818cf8' : '#6366f1',+ },+ },+ axis: {+ x: {+ min: 0,+ label: {+ text: t('project.seo.avgPosition'),+ position: 'outer-center',+ },+ tick: {+ fit: false,+ format: (d: number) => Number(d).toFixed(0),+ },+ },+ y: {+ min: 0,+ max: 100,+ padding: { top: 0, bottom: 0 },+ label: { text: t('project.seo.avgCTR'), position: 'outer-middle' },+ tick: {+ format: (d: number) => `${d}%`,+ },+ },+ },+ point: {+ r: (d: any) => {+ if (!d || d.index === undefined) return 4+ const imp = impressions[d.index]+ if (!imp) return 4+ return 4 + 16 * Math.sqrt(imp / maxImp)+ },+ },+ grid: {+ x: {+ lines: [+ {+ value: avgPos,+ text: `${t('project.seo.avgPosition')}: ${avgPos.toFixed(1)}`,+ position: 'start',+ class: 'annotation-line',+ },+ ],+ },+ y: {+ lines: [+ {+ value: avgCtr,+ text: `${t('project.seo.avgCTR')}: ${avgCtr.toFixed(1)}%`,+ position: 'start',+ class: 'annotation-line',+ },+ ],+ },+ },+ tooltip: {+ contents: (items: any) => {+ const d = items[0]+ const name = names[d.index]+ const imp = impressions[d.index]++ return `<ul class='bg-gray-50 dark:text-gray-50 dark:bg-slate-900 rounded-md ring-1 ring-black/10 px-2 py-1 text-xs md:text-sm shadow-md z-50'>+ <li class='font-semibold pb-1 mb-1 border-b border-gray-200 dark:border-slate-800 break-all'>${name}</li>+ <li class='flex justify-between items-center py-px leading-snug'>+ <span class='mr-4'>${t('project.seo.position')}:</span>+ <span class='font-mono whitespace-nowrap'>${d.x.toFixed(1)}</span>+ </li>+ <li class='flex justify-between items-center py-px leading-snug'>+ <span class='mr-4'>${t('project.seo.ctr')}:</span>+ <span class='font-mono whitespace-nowrap'>${d.value.toFixed(1)}%</span>+ </li>+ <li class='flex justify-between items-center py-px leading-snug'>+ <span class='mr-4'>${t('project.seo.impressions')}:</span>+ <span class='font-mono whitespace-nowrap'>${nFormatter(imp, 1)}</span>+ </li>+ </ul>`+ },+ },+ legend: {+ show: false,+ },+ transition: {+ duration: 200,+ },+ }+ }, [quadrantData, data?.summary, theme, t])+const chartOptions: ChartOptions = useMemo(() => {if (!aggregatedSeries.length) return {}@@ -1051,8 +1164,8 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {rowMapper={refRowMapper}/><div className='overflow-hidden rounded-lg border border-gray-200 bg-white px-4 py-3 dark:border-slate-800/60 dark:bg-slate-900/25'>- <div className='mb-1 flex items-center gap-2'>- <MagnifyingGlassIcon className='size-5 text-gray-500 dark:text-gray-400' />+ <div className='mb-1 flex items-center gap-1 text-gray-900 dark:text-gray-50'>+ <MagnifyingGlassIcon className='size-5' /><Text size='sm' weight='semibold'>{t('project.seo.brandedTraffic')}</Text>@@ -1065,11 +1178,7 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {/>) : (<div className='flex h-32 items-center justify-center'>- <Text- size='xs'- colour='inherit'- className='text-gray-400 dark:text-gray-500'- >+ <Text size='xs' colour='inherit'>{t('project.seo.noBrandData')}</Text></div>@@ -1106,6 +1215,46 @@ const SEOViewInner = ({ projectId, tnMapping }: SEOViewProps) => {/></div>+ <div className='mt-3'>+ <PanelContainer+ name={t('project.seo.quadrant')}+ icon={<TargetIcon className='size-5' />}+ type='quadrant'+ tooltip={+ <Tooltip+ text={+ <span className='whitespace-pre-line'>+ <Trans+ i18nKey='project.seo.quadrantTooltip'+ components={{+ highlight: <span className='font-semibold' />,+ }}+ />+ </span>+ }+ tooltipNode={+ <InfoIcon className='size-4 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300' />+ }+ />+ }+ contentClassName=''+ >+ {quadrantData ? (+ <BillboardChart+ options={quadrantChartOptions}+ className='h-[400px] [&_.bb-circle]:fill-indigo-500/60 [&_.bb-circle]:stroke-indigo-600 [&_.bb-circle]:stroke-1 dark:[&_.bb-circle]:fill-indigo-400/60 dark:[&_.bb-circle]:stroke-indigo-300'+ deps={[quadrantData, theme, t]}+ />+ ) : (+ <div className='flex h-80 items-center justify-center'>+ <Text size='xs' colour='inherit'>+ {t('project.noParamData')}+ </Text>+ </div>+ )}+ </PanelContainer>+ </div>+<div className='mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2'><Panelname={t('project.location')}diff --git a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx b/web/app/pages/Project/tabs/Traffic/TrafficView.tsxindex cfab31886..b6ae65b36 100644--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx@@ -1435,21 +1435,21 @@ const TrafficViewInner = ({panelsActiveTabs.source === 'keywords'? [{- header: t('project.impressions'),+ header: t('project.seo.impressions'),render: (entry: any) => entry.impressions,sortLabel: 'impressions',getSortValue: (entry: any) =>Number(entry.impressions || 0),},{- header: t('project.position'),+ header: t('project.seo.position'),render: (entry: any) => entry.position,sortLabel: 'position',getSortValue: (entry: any) =>Number(entry.position || 0),},{- header: t('project.ctr'),+ header: t('project.seo.ctr'),render: (entry: any) => `${entry.ctr}%`,sortLabel: 'ctr',getSortValue: (entry: any) =>diff --git a/web/app/styles/ProjectViewStyle.css b/web/app/styles/ProjectViewStyle.cssindex eb373c612..ccfeaf57c 100644--- a/web/app/styles/ProjectViewStyle.css+++ b/web/app/styles/ProjectViewStyle.css@@ -209,12 +209,14 @@ body.dark .bb-ygrid {}/* Annotation lines */-.bb-xgrid-line.annotation-line {+.bb-xgrid-line.annotation-line,+.bb-ygrid-line.annotation-line {pointer-events: all;cursor: pointer;}-.bb-xgrid-line.annotation-line line {+.bb-xgrid-line.annotation-line line,+.bb-ygrid-line.annotation-line line {stroke: var(--color-slate-500);stroke-width: 1;stroke-dasharray: 4 3;@@ -225,7 +227,8 @@ body.dark .bb-ygrid {stroke: var(--color-slate-500);}-.bb-xgrid-line.annotation-line text {+.bb-xgrid-line.annotation-line text,+.bb-ygrid-line.annotation-line text {font-size: 10px;font-weight: 600;fill: var(--color-gray-700);@@ -239,7 +242,16 @@ body.dark .bb-ygrid {pointer-events: all;}-body.dark .bb-xgrid-line.annotation-line text {+.bb-ygrid-line.annotation-line text {+ transform: translateY(-14px);+}++body.dark .bb-xgrid-line.annotation-line text,+body.dark .bb-ygrid-line.annotation-line text {fill: var(--color-gray-300);stroke: var(--color-slate-900);}++body.dark .bb-chart-arc path {+ stroke: var(--color-slate-900);+}diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex 65a4f3101..0ac03ebff 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -1394,6 +1394,8 @@"impressions": "Impressions","avgCTR": "Average CTR","avgPosition": "Average Position",+ "position": "Position",+ "ctr": "CTR","clicksAndImpressions": "Clicks & Impressions","avgPositionChart": "Average Position","ctrVsPosition": "CTR vs Position",@@ -1403,8 +1405,6 @@"pagesForQuery": "Pages ranking for this query","page": "Page","query": "Query",- "ctr": "CTR",- "position": "Pos.","lowerIsBetter": "Lower is better","yourCTR": "Your CTR","benchmark": "Benchmark",@@ -1415,7 +1415,9 @@"nonBranded": "Non-branded","brandedTraffic": "Branded traffic","others": "Others",- "noBrandData": "No query data"+ "noBrandData": "No query data",+ "quadrant": "SEO Quadrant",+ "quadrantTooltip": "Each bubble is a search query. X-axis is ranking position (left = higher rank), Y-axis is click-through rate, and bubble size reflects impressions.\n\n<highlight>Top-left</highlight>: high rank + high CTR (your best performers).\n<highlight>Bottom-left</highlight>: high rank but low CTR (improve your title & description).\n<highlight>Top-right</highlight>: low rank but high CTR (boost these to page 1 for big gains).\n<highlight>Bottom-right</highlight>: low rank + low CTR (lowest priority)."},"passwordProtectedHint": "Please enter the password to view this dashboard.","captchaCompletions": "CAPTCHA completions",@@ -1423,9 +1425,6 @@"editAnnotation": "Edit annotation","deleteAnnotation": "Delete annotation","annotationsViewOnly": "Only project managers can add annotations",- "impressions": "Impressions",- "position": "Position",- "ctr": "CTR","backToStats": "Back to stats","directNone": "Direct / None","loadingMapData": "Loading map data...",