get_all_kpis(7, false); if (!is_array($data)) { $data = []; } $top_bots = $database->get_visits_by_family(7, false); $top_bots = is_array($top_bots) ? array_slice($top_bots, 0, 5) : []; $top_pages = $kpis->get_top_topics(5, 7); $top_pages = is_array($top_pages) ? $top_pages : []; $ai_referrer = isset($data['ai_referrer_insights']) && is_array($data['ai_referrer_insights']) ? $data['ai_referrer_insights'] : ['top_sources' => [], 'total_visits' => 0]; $pressure = isset($data['ai_pressure']) && is_array($data['ai_pressure']) ? $data['ai_pressure'] : ['percentage' => 0, 'status' => 'unknown', 'message' => 'Insufficient data']; $authority = isset($data['ai_authority_score']) && is_array($data['ai_authority_score']) ? $data['ai_authority_score'] : ['score' => 0, 'grade' => 'N/A', 'status' => 'waiting', 'message' => 'Waiting for sufficient data...']; $blocked = isset($data['blocked_stats']) && is_array($data['blocked_stats']) ? $data['blocked_stats'] : ['total' => 0, 'top_family' => '-']; $intentions = isset($data['training_vs_inference']) && is_array($data['training_vs_inference']) ? $data['training_vs_inference'] : ['counts' => [], 'labels' => [], 'total' => 0]; $intentions['counts'] = isset($intentions['counts']) && is_array($intentions['counts']) ? $intentions['counts'] : []; $intentions['labels'] = isset($intentions['labels']) && is_array($intentions['labels']) ? $intentions['labels'] : []; $intentions['total'] = isset($intentions['total']) ? (int) $intentions['total'] : (int) array_sum($intentions['counts']); $site_name = get_bloginfo('name'); $site_url = get_bloginfo('url'); $period = gmdate('d/m/Y', strtotime('-7 days')) . ' โ€“ ' . gmdate('d/m/Y'); $subject = sprintf('[%s] Weekly AI Analytics Report โ€“ %s', $site_name, gmdate('d/m/Y')); $body = $this->get_html($site_name, $site_url, $period, $pressure, $authority, $blocked, $intentions, $top_bots, $top_pages, $ai_referrer); $headers = ['Content-Type: text/html; charset=UTF-8']; wp_mail($to, $subject, $body, $headers); } private function get_html($site_name, $site_url, $period, $pressure, $authority, $blocked, $intentions, $top_bots, $top_pages, $ai_referrer) { $dashboard_url = admin_url('admin.php?page=almaweb-ai-visitor-analytics'); $pressure_colors = [ 'healthy' => '#10b981', 'moderate' => '#f59e0b', 'high' => '#f97316', 'critical' => '#ef4444', 'unknown' => '#94a3b8', ]; $pressure_color = $pressure_colors[$pressure['status']] ?? '#94a3b8'; $authority_colors = [ 'elite' => '#7c3aed', 'excellent' => '#10b981', 'good' => '#3b82f6', 'emerging' => '#f59e0b', 'minimal' => '#94a3b8', 'waiting' => '#94a3b8', ]; $authority_color = $authority_colors[$authority['status']] ?? '#94a3b8'; $has_intentions = $intentions['total'] > 0; $has_data = $has_intentions || !empty($top_bots) || !empty($top_pages) || !empty($ai_referrer['top_sources']); $empty_row = 'No data recorded for this period.'; ob_start(); ?>
0) : ?>

AlmaWeb AI Visitor Analytics

Key Indicators โ€“ Last 7 days

%

AI Pressure

(/100)

AI Authority Score

No AI visits were recorded during this period.
If your site uses a cache plugin or a server cache (WP Rocket, LiteSpeed Cache, W3 Total Cache, Cloudflare, host-level cache...), pages served from cache never reach WordPress and cannot be logged. This is normal: only uncached requests are tracked.

Bot Intentions

'#10b981', 'search' => '#3b82f6', 'training' => '#f59e0b', 'scraping' => '#ef4444', 'unknown' => '#94a3b8', ]; $total_intentions = $intentions['total'] > 0 ? $intentions['total'] : 1; foreach ($intentions['counts'] as $key => $count) : $count = (int) $count; if ($count <= 0) continue; $pct = round(($count / $total_intentions) * 100); $color = $intention_colors[$key] ?? '#94a3b8'; $label = $intentions['labels'][$key] ?? ucfirst($key); ?>
(%)

Top Bot Families

$bot) : $bg = $i % 2 === 0 ? '#f8fafc' : '#ffffff'; ?>
Family Visits

Top Scraped Pages

$page) : $bg = $i % 2 === 0 ? '#f8fafc' : '#ffffff'; $title = $page['display_title'] ?? $page['page_title'] ?? $page['request_url'] ?? '-'; ?>
Page Visits

Human Traffic from AI Platforms

$source) : $bg = $i % 2 === 0 ? '#f8fafc' : '#ffffff'; ?>
Source Visits
๐Ÿšซ blocked requests this week โ€” top family:
View full dashboard โ†’

ยท AlmaWeb AI Visitor Analytics