import React, { useEffect, useState } from 'react'; import { __, sprintf } from '@wordpress/i18n'; import { api } from '../api'; import { Card, Button, Badge, Notice, Field, Switch, MetricGrid, Sparkline, RankBar, SegmentBar } from './ui'; import Explain from './Explain'; import { IconChart, IconRefresh, IconSparkle, IconExternal } from './icons'; /** * Matomo. * * Two reasons it is here, and the second is the interesting one. Plenty of * sites cannot use Google Analytics at all, so a paid SEO plugin that only * speaks GA4 is unusable for them. And the only hard evidence that any of this * work is paying off is a visit whose referrer is an AI assistant — Matomo * returns the full referrer list unsampled and without a processing delay, so * that question has an exact answer here rather than an estimate. */ export default function MatomoPanel({ settings, onSave, saving }) { const [data, setData] = useState(null); const [error, setError] = useState(null); const [busy, setBusy] = useState(false); const [token, setToken] = useState(''); const [verified, setVerified] = useState(null); const [days, setDays] = useState(30); const [draft, setDraft] = useState(null); const s = draft || settings || {}; const load = (d = days) => { setBusy(true); setError(null); api .get(`/analytics/matomo?days=${d}`) .then(setData) .catch((e) => setError(e.message)) .finally(() => setBusy(false)); }; useEffect(() => { load(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const patch = (p) => setDraft({ ...s, ...p }); const saveAll = async () => { setBusy(true); setError(null); try { // The token goes to its own endpoint because it is stored // encrypted and never comes back — sending it with the settings // would mean the settings payload carried a secret it cannot show. if (token) { await api.put('/analytics/matomo', { token }); setToken(''); } await onSave(s); setDraft(null); load(); } catch (e) { setError(e.message); } finally { setBusy(false); } }; const verify = async () => { setBusy(true); setVerified(null); setError(null); try { setVerified(await api.post('/analytics/matomo/verify')); } catch (e) { setError(e.message); } finally { setBusy(false); } }; const ai = data?.assistants; return (
| {__('Page', 'ai-rank-suite')} | {__('Views', 'ai-rank-suite')} |
|---|---|
| {p.path} | {p.views.toLocaleString()} |
{__('Cookieless is on by default. Matomo can measure without setting a cookie, and a site that chose Matomo over Google Analytics has usually chosen it for exactly that reason. Leave the tracking code off if Matomo is already installed by another plugin or by your theme — two snippets means every visit counted twice.', 'ai-rank-suite')}
{__('A visit is attributed to an assistant only when the browser sends a referrer naming it. Several assistants strip the referrer entirely, some open links in an in-app browser that sends nothing, and anyone who reads an answer and then types your name into a search box arrives as organic search. So the real influence of AI answers is always larger than this figure — treat it as the part you can prove.', 'ai-rank-suite')}
{__('The direction still matters more than the level. If this number is climbing month over month while your published pages are unchanged, the citations are working.', 'ai-rank-suite')}