Hybrid Setup - Maximum Bot Detection
Catch every bot, including fast crawlers like OpenAI that leave before external scripts load. Combines immediate inline tracking with enhanced bot detection signals.
Why Use Hybrid Setup?
The Problem
Some AI crawlers (notably OpenAI's crawlers) execute JavaScript but leave pages before external scripts finish loading. The standard async script approach misses these fast bots entirely, leading to underreported AI traffic.
The Solution
Hybrid setup uses a critical inline pixel that fires immediately (catches fast bots), plus the full external script that adds enhanced bot detection signals. Deduplication ensures you don't double-count visits.
How It Works
Critical Pixel Fires Immediately
Inline script executes synchronously. Tracks URL, referrer, screen size, and viewport. Uses sendBeacon for reliability.
External Script Adds Enhanced Data
Full tracking script loads asynchronously, doesn't block page. Adds connection type, session management, SPA tracking, and other advanced features.
Backend Deduplicates Automatically
Server-side deduplication using session ID and timestamp (10-second window). Only one pageview recorded, even though both pixels fire.
Installation
Add the following code to your HTML, just before the closing </body> tag:
<!-- AI Search Index Tracking (Hybrid Setup) -->
<!-- Critical pixel fires immediately to catch fast bots -->
<script>
;(function(){try{var key='_asi_sid';var sid;try{sid=sessionStorage.getItem(key);if(!sid){sid=Math.random().toString(36).substring(2,15);try{sessionStorage.setItem(key,sid);}catch(_){}}}catch(_){sid=Math.random().toString(36).substring(2,15);}var p=new URLSearchParams();p.set('tid','YOUR_TRACKING_ID');p.set('url',location.href);p.set('ts',Date.now());p.set('sid',sid);if(document.referrer)p.set('ref',document.referrer);if(screen){p.set('sw',screen.width);p.set('sh',screen.height);}p.set('vw',innerWidth);p.set('vh',innerHeight);var url='https://www.aisearchindex.com/api/pixel?'+p;if(navigator.sendBeacon){navigator.sendBeacon(url);}else{var img=new Image(1,1);img.src=url;img.style.cssText='position:absolute;left:-9999px;visibility:hidden';img.alt='';if(document.body){document.body.appendChild(img);}}window.__asi_critical_fired=true;}catch(_){}})();
</script>
<!-- Full tracking script adds enhanced bot detection (loads async) -->
<script
src="https://www.aisearchindex.com/pixel.js"
data-tid="YOUR_TRACKING_ID"
async
></script>
<!-- Fallback for browsers with JavaScript disabled -->
<noscript><img src="https://www.aisearchindex.com/api/pixel?tid=YOUR_TRACKING_ID" width="1" height="1" style="position:absolute;left:-9999px;visibility:hidden" alt="" /></noscript>Important: Replace YOUR_TRACKING_ID with your actual tracking ID from the dashboard.
Performance Impact
Critical Pixel
~600 bytes minified. Executes in <1ms. Zero blocking.
External Script
~2KB gzipped. Loads async. CDN cached.
Single Page Apps (SPA)
For React, Vue, Next.js, and other SPAs, add the data-spa="true" attribute to the external script:
<!-- Critical pixel (same as above) -->
<script>
;(function(){...})();
</script>
<!-- Full script with SPA support -->
<script
src="https://www.aisearchindex.com/pixel.js"
data-tid="YOUR_TRACKING_ID"
data-spa="true"
async
></script>The critical pixel only tracks the initial page load. The external script handles all client-side navigations.
Setup Comparison
| Feature | Standard | Hybrid |
|---|---|---|
| Catches fast bots (OpenAI) | ❌ | ✅ |
| Catches slow bots | ✅ | ✅ |
| Enhanced bot detection signals | ✅ | ✅ |
| SPA support | ✅ | ✅ |
| Session tracking | ✅ | ✅ |
| Setup complexity | Simple | Moderate |
| Code size (total) | ~2KB | ~2.6KB |
| Bot detection coverage | ~85% | ~98% |
When to Use Hybrid Setup
✅ Use Hybrid If:
- You need to track OpenAI and other fast crawlers
- You want maximum bot detection coverage
- You're seeing suspicious gaps in your AI traffic data
- Your content is being used in AI responses but not showing in analytics
Standard Setup Is Fine If:
- You only need to track slower bots (Google crawlers, Perplexity, etc.)
- You prefer simpler setup
- You don't mind missing some fast bots