=== Kansoku Lab Tracker ===
Contributors:      aikansokulab
Tags:              ai, crawler, tracking, seo, gptbot
Requires at least: 6.0
Tested up to:      6.9
Requires PHP:      7.4
Stable tag:        1.0.6
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Track AI crawler visits (GPTBot, ClaudeBot, PerplexityBot, etc.) server-side and visualize them in the AI Kansoku Lab dashboard.

== Description ==

**AI Kansoku Lab Tracker** detects visits from AI crawlers such as GPTBot, ClaudeBot, and PerplexityBot using PHP server-side detection. Because AI crawlers do not execute JavaScript, traditional analytics tools like GA4 cannot capture these visits. This plugin solves that problem.

= Features =

* **Server-side detection** - Captures AI crawlers that do not run JavaScript
* **14 crawler patterns** - GPTBot, ChatGPT-User, ClaudeBot, PerplexityBot, ByteSpider, Meta-ExternalAgent, Google-Extended, Grok, AppleBot, DeepSeek, and more
* **Explicit opt-in** - External tracking only activates when you enable it via checkbox
* **Zero performance impact** - Uses non-blocking POST requests (blocking: false)
* **Simple setup** - Just paste your Site ID, enable tracking, and save
* **WordPress standards** - Uses wp_remote_post, register_setting, nonce verification, and proper escaping throughout
* **Front-end only** - Does not fire on admin, cron, AJAX, or REST API requests

= How It Works =

When a front-end page is requested, the plugin checks the User-Agent string against known AI crawler patterns. If a match is found — and you have explicitly enabled external tracking — it sends an asynchronous POST request to the AI Kansoku Lab API to log the visit. The site visitor experiences no delay.

= External Service =

This plugin connects to an external API: **AI Kansoku Lab** (https://www.ai-kansoku.com).

External tracking is **opt-in only**. Data is only transmitted after you explicitly enable it in the settings page.

When an AI crawler is detected, the following metadata is sent:
* User-Agent string of the detected AI crawler
* URL path of the visited page
* Your Site ID (configured in plugin settings)

This plugin does not intentionally collect cookies, account credentials, or form contents.

* Service URL: https://www.ai-kansoku.com
* Privacy Policy: https://www.ai-kansoku.com/privacy
* Terms of Service: https://www.blog.ai-kansoku.com/terms

= Requirements =

* A free account at AI Kansoku Lab (https://www.ai-kansoku.com)
* Your Site ID from the dashboard

== Installation ==

1. Upload the plugin ZIP via Plugins > Add New > Upload Plugin
2. Activate the plugin
3. Go to Settings > AI Kansoku Lab
4. Enter your Site ID from https://www.ai-kansoku.com/dashboard
5. Check "Enable external tracking to AI Kansoku Lab"
6. Click Save Settings

== Frequently Asked Questions ==

= Where do I find my Site ID? =

Log in to AI Kansoku Lab (https://www.ai-kansoku.com), register your site, and copy the Site ID shown in the Tracking Code section of your dashboard.

= Will this slow down my site? =

No. The plugin uses `wp_remote_post` with `blocking: false`, so the HTTP request is fired asynchronously and does not delay page rendering.

= Does it run on every request? =

No. The plugin only fires on front-end page requests when both a Site ID is set and external tracking is explicitly enabled. Admin pages, AJAX calls, REST API requests, and WP-Cron jobs are excluded.

= Can it detect crawlers that do not run JavaScript? =

Yes. That is the main purpose of this plugin. GA4 and other JavaScript-based tools miss AI crawlers entirely. This plugin detects them at the PHP level using the HTTP_USER_AGENT server variable.

= Which AI crawlers are supported? =

GPTBot, ChatGPT-User, OAI-SearchBot, ClaudeBot, Anthropic-AI, ByteSpider, Meta-ExternalAgent, Google-Extended, Grok, xAI, AppleBot, DeepSeek, CopilotBot, PerplexityBot.

= What happens when I uninstall the plugin? =

All plugin settings stored in the WordPress database are removed automatically on uninstall.

== Changelog ==

= 1.0.6 =
* Renamed plugin to Kansoku Lab Tracker for WordPress.org guidelines compliance
* Updated all prefixes from AIK_ to AIKLAB_ to meet 4+ character prefix requirement
* Replaced inline <style> block with wp_enqueue_style() and wp_add_inline_style()
* Updated Terms of Service URL

= 1.0.4 =
* Replaced HTML-mixed echo with PHP template syntax in status panel
* Changed Tested up to from 6.9 to 6.8 for accuracy

= 1.0.3 =
* Changed hook from `init` to `template_redirect` for cleaner front-end-only targeting
* Removed redundant is_admin/cron/AJAX/REST guards (handled by hook context)
* Replaced Markdown link syntax in readme with plain URLs for better compatibility

= 1.0.2 =
* Added explicit opt-in checkbox — external tracking now requires user consent
* Unified all URLs to https://www.ai-kansoku.com
* Refined crawler regex (replaced broad /anthropic/ with /anthropic-ai/)
* Updated privacy wording to accurately reflect transmitted data
* Status panel now shows tracking state (Active / Disabled / Not configured)

= 1.0.1 =
* Changed tracking from GET to POST request for cleaner data transmission
* Increased timeout from 0.1s to 1s for better reliability
* Restricted tracking to front-end requests only (excludes admin, AJAX, REST, cron)
* Added explicit External API Notice in settings page
* Added uninstall.php to clean up database options on removal

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.0.2 =
Added explicit opt-in checkbox for external tracking. Please re-enable tracking in Settings > AI Kansoku Lab after updating.

== Privacy Policy ==

This plugin connects to an external service to log AI crawler visits.

External tracking is opt-in only and only activates after explicit user consent via the settings page.

Data transmitted to AI Kansoku Lab (https://www.ai-kansoku.com) when tracking is enabled:
* User-Agent string of the detected AI crawler
* URL path of the visited page
* Site ID configured in plugin settings

This plugin does not intentionally collect cookies, account credentials, or form contents.

Full privacy policy: https://www.ai-kansoku.com/privacy
