Админка: источники трафика (referrer + UTM)

- Маячок /api/hit шлёт {ref: document.referrer, url} → сервер определяет источник
- _source_from: приоритет utm_source, иначе домен referrer (Google/Yandex/Telegram/VK/…),
  переходы внутри сайта и пустой referrer → «Прямые заходы»
- Таблица WEB_SOURCES(day,source,count); в админке раздел «Источники трафика» (источник/заходов/доля)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
berkio_admin_gitea
2026-07-07 13:39:15 +00:00
parent 4507c4bad3
commit ee5ef3f08b
2 changed files with 81 additions and 5 deletions

View File

@@ -2839,7 +2839,8 @@
try {
if (!sessionStorage.getItem('p2s_hit')) {
sessionStorage.setItem('p2s_hit', '1');
fetch('/api/hit', { method: 'POST', keepalive: true }).catch(function () {});
fetch('/api/hit', { method: 'POST', keepalive: true, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ref: document.referrer || '', url: location.href || '' }) }).catch(function () {});
}
} catch (_) {}
// Возврат после OAuth: чистим ?login и показываем ошибку при неудаче