CleverSearch

Tracker Script Installation

Learn how to install and configure the CleverSearch tracker script on your website to enable AI-powered content optimization and analytics.

What This Script Does
💉

Automatic Content Injection

Dynamically injects optimized titles, meta descriptions, keywords, FAQs, and content paragraphs

🔄

SPA Navigation Support

Automatically detects and handles single-page application route changes (Next.js, React, Vue, Angular)

📊

Performance Tracking

Tracks Core Web Vitals (LCP, FID, CLS) and page performance metrics

📈

Analytics Collection

Collects user behavior data, page views, and interaction events

🛡️

Error Handling

Robust error handling with automatic retries and graceful degradation

🔍

Debug Mode

Built-in debugging capabilities for troubleshooting integration issues

Platform-Specific Installation

Next.jsReact framework with App Router
Use Next.js Script component for optimal performance
<Script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  strategy="beforeInteractive"
  async
  data-config='{"SITE_ID": "your-site-id"}'
/>
ReactCreate React App, Vite, or other React setups
Place in public/index.html or equivalent
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
WordPressTraditional WordPress sites
Add to header.php or use a plugin
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
ShopifyShopify store themes
Add to theme.liquid in the <head> section
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
WixWix website builder
Add via Custom Code element in Wix Editor
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
SquarespaceSquarespace websites
Add via Code Injection in Site Settings
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
OtherAny HTML website
Place in the <head> section of your HTML
<script
  src="https://backend.cleversearch.ai/tracker/v1/tracker.js"
  async
  defer
  data-config='{"SITE_ID": "your-site-id"}'
></script>
Configuration Options

Required Configuration

data-config='{"SITE_ID": "your-site-id"}'

Replace "your-site-id" with your actual site ID from the dashboard.

Optional Configuration

data-config='{
  "SITE_ID": "your-site-id",
  "API_BASE": "https://backend.cleversearch.ai",
  "DEBUG_MODE": false,
  "RETRY_ATTEMPTS": 3,
  "TIMEOUT": 2000
}'

Most users only need the SITE_ID. Other options are for advanced use cases.

Troubleshooting

Script not loading

Check that the script URL is accessible and your SITE_ID is correct

Content not injecting

Verify your site ID and check browser console for errors

SPA navigation not working

Ensure the script loads before your SPA framework initializes

Performance impact

The script is optimized for minimal impact, but check network tab for any issues

Debug Mode

Enable debug mode to see detailed logging in the browser console. This helps troubleshoot integration issues and verify the script is working correctly.

Enable Debug Mode

Method 1: URL Parameter

?clever-search-debug=true

Method 2: Configuration

data-config='{"SITE_ID": "your-site-id", "DEBUG_MODE": true}'

Global API

The script exposes a global API for manual control:

window.LLMOptimizer.refresh() // Refresh contentwindow.LLMOptimizer.getStats() // Get statisticswindow.LLMOptimizer.enableDebug() // Enable debug mode

Next Steps

After installing the tracker script, you can start optimizing your content and tracking performance.