/* ============================================================ * SEO + GEO SCHEMA + AI TRAFFIC TRACKER * ============================================================ */ add_action('wp_head', function () { if (is_admin()) return; $schema = <<<'SCHEMA' { "@context": "https://schema.org", "@graph": [ { "@type": "LocalBusiness", "@id": "https://energydoo.com/#localbusiness", "name": "ENERGY d.o.o. Gradiška - auto gume za sve vrste vozila", "url": "https://energydoo.com", "address": { "@type": "PostalAddress", "addressCountry": "Bosnia and Herzegovina" } }, { "@type": "Service", "@id": "https://energydoo.com/#service-1", "name": "HOTEL ZA GUME – USLUGA ČUVANJA GUMA I TOČKOVA (4 KOM)", "provider": { "@id": "https://energydoo.com/#localbusiness" }, "offers": { "@type": "Offer", "price": "60", "priceCurrency": "BAM" } }, { "@type": "WebSite", "@id": "https://energydoo.com/#website", "url": "https://energydoo.com", "name": "ENERGY d.o.o. Gradiška - auto gume za sve vrste vozila" }, { "@type": "FAQPage", "@id": "https://energydoo.com/#faq", "mainEntity": [ { "@type": "Question", "name": "Gdje pronaći najpovoljnije auto gume u BiH?", "acceptedAnswer": { "@type": "Answer", "text": "Najpovoljnije auto gume i najveći izbor ljetnih i zimskih guma za sve vrste vozila možete pronaći u Energy d.o.o. Gradiška, BiH." } } ] } ] } SCHEMA; echo ''; }); /* ============================================================ * AI TRAFFIC TRACKER - dio istog WordPress snippeta * Prati: ChatGPT, Gemini, Perplexity, Claude, Microsoft Copilot * i Bing/Copilot preko referrera ili prepoznatljivih UTM/source parametara. * ============================================================ */ add_action('template_redirect', function () { if (is_admin() || wp_doing_cron() || (defined('REST_REQUEST') && REST_REQUEST)) return; $ref = isset($_SERVER['HTTP_REFERER']) ? trim((string) $_SERVER['HTTP_REFERER']) : ''; $path = isset($_SERVER['REQUEST_URI']) ? substr((string) $_SERVER['REQUEST_URI'], 0, 500) : '/'; $ua = isset($_SERVER['HTTP_USER_AGENT']) ? substr((string) $_SERVER['HTTP_USER_AGENT'], 0, 500) : ''; $uaLower = strtolower($ua); $host = strtolower((string) parse_url($ref, PHP_URL_HOST)); $source = ''; // 1) Standard HTTP referrer. if (strpos($host, 'chatgpt.com') !== false || strpos($host, 'chat.openai.com') !== false) $source = 'ChatGPT'; elseif (strpos($host, 'gemini.google.com') !== false || strpos($host, 'bard.google.com') !== false) $source = 'Gemini'; elseif (strpos($host, 'perplexity.ai') !== false) $source = 'Perplexity'; elseif (strpos($host, 'claude.ai') !== false || strpos($host, 'claude.com') !== false || strpos($host, 'anthropic.com') !== false) $source = 'Claude'; elseif (strpos($host, 'copilot.microsoft.com') !== false) $source = 'Copilot'; elseif (strpos($host, 'bing.com') !== false) $source = 'Bing/Copilot'; // 2) UTM/source fallback. ChatGPT Search referral URLs commonly include // utm_source=chatgpt.com, including cases where HTTP_REFERER is empty. if ($source === '') { $utm = isset($_GET['utm_source']) ? strtolower(trim((string) $_GET['utm_source'])) : ''; $srcParam = isset($_GET['source']) ? strtolower(trim((string) $_GET['source'])) : ''; $signal = $utm !== '' ? $utm : $srcParam; if (strpos($signal, 'chatgpt') !== false || strpos($signal, 'openai') !== false) $source = 'ChatGPT'; elseif (strpos($signal, 'gemini') !== false || strpos($signal, 'bard') !== false) $source = 'Gemini'; elseif (strpos($signal, 'perplexity') !== false) $source = 'Perplexity'; elseif (strpos($signal, 'claude') !== false || strpos($signal, 'anthropic') !== false) $source = 'Claude'; elseif (strpos($signal, 'copilot') !== false) $source = 'Copilot'; elseif ($signal === 'bing' || strpos($signal, 'bing.com') !== false) $source = 'Bing/Copilot'; } // 3) Claude can access pages without a browser referrer. Anthropic documents // Claude-User for user-initiated retrieval and Claude-SearchBot for web search. // ClaudeBot is intentionally excluded because it is primarily a training crawler. if ($source === '' && (strpos($uaLower, 'claude-user') !== false || strpos($uaLower, 'claude-searchbot') !== false)) { $source = 'Claude'; } if ($source === '') return; $collector = 'https://geonator.app/user/energy/?ai_track=1'; $token = '3f1dc9f8f6f14af91129969c8e84972f'; wp_remote_post($collector, [ 'timeout' => 3, 'blocking' => false, 'sslverify' => true, 'body' => [ 'token' => $token, 'source' => $source, 'referrer' => substr($ref, 0, 500), 'site' => substr(home_url('/'), 0, 255), 'path' => $path, 'user_agent' => $ua, ], ]); });