infrangible / m2-ai-traffic
Shows what AI brings to the shop: visitors and orders from ChatGPT, Perplexity, Copilot, Gemini and Claude, and the visits of AI crawlers, in a report with conversion rate and revenue.
Package info
github.com/infrangible-dev/m2-ai-traffic
Type:magento2-module
pkg:composer/infrangible/m2-ai-traffic
Requires
- php: >=8.1
- fewedev/base: ~2.4.3
- infrangible/m2-ai-visibility: ~1.1.0
- infrangible/m2-foundation: ~3.0.2
- magento/framework: ~103.0.6
- magento/module-backend: ~102.0.6
- magento/module-config: ~101.2.6
- magento/module-customer: ~103.0.6
- magento/module-directory: ~100.4.6
- magento/module-page-cache: ~100.4.6
- magento/module-reports: ~100.4.6
- magento/module-sales: ~103.0.6
- magento/module-store: ~101.1.6
- magento/module-ui: ~101.2.6
- psr/log: ~2.0.0||~3.0.0
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 14:06:48 UTC
README
Shows what AI brings to the shop: visitors and orders from the AI assistants ChatGPT, Perplexity, Copilot, Gemini and Claude, and the visits of the AI crawlers, in a report with conversion rate and revenue. Builds on Infrangible AI Visibility, whose list of AI crawlers it uses.
Report
Reports > Marketing > AI Traffic shows for the last 7, 30, 90 or 365 days, for all or one store view:
- Visitors from AI assistants: ChatGPT, Perplexity, Copilot, Gemini and Claude, with visits, orders (without canceled ones), conversion rate and revenue in the base currency.
- AI crawlers: the requests of each crawler of the robots.txt groups of AI Visibility (training of AI models, AI
search, user requests) by page type: pages, Markdown versions,
llms.txt/llms-full.txtandrobots.txt. Google-Extended and Applebot-Extended are no own crawlers (Google and Apple use the content of their search engine crawlers), so they do not appear.
Visitors and orders
A small script at the end of every storefront page (plain JavaScript, works in Luma and Hyvä, also on pages from the
page cache) recognizes a visit from an assistant by the referrer (chatgpt.com, chat.openai.com, perplexity.ai,
copilot.microsoft.com, copilot.com, gemini.google.com, claude.ai and their subdomains) or by the parameter
utm_source that some assistants add to their links. It sends the assistant to /aitraffic/visit, which counts the
visit once per session and keeps the assistant in the customer session (which exists for guests as well).
When the visitor orders in that session, the assistant is saved on the order (column ai_source of sales_order and
sales_order_grid): the order view shows it in the section "AI Assistant", and the order grid has the filterable
column "AI Assistant". Orders through the storefront checkout of Luma and Hyvä and through the REST API with the
customer session are marked.
Crawlers and Varnish
A plugin on Magento's front controller counts requests whose user agent contains one of the AI crawlers, before the built-in page cache, so pages from the cache are counted as well.
Varnish answers cached pages without Magento, so behind Varnish their crawler requests are not counted, and the report
says so. The setting "Count Crawlers behind Varnish" changes the VCL that Magento generates
(bin/magento varnish:vcl:generate and the export in the admin) so that AI crawlers are sent past the cache to Magento;
all their requests are then counted, at the cost of more load on the server. Generate the VCL again and load it into
Varnish after changing the setting. A VCL written by hand needs the same rule at the start of vcl_recv:
if ((req.method == "GET" || req.method == "HEAD") && req.http.User-Agent ~ "(?i)(GPTBot|ClaudeBot|CCBot|Bytespider|meta-externalagent|OAI-SearchBot|Claude-SearchBot|PerplexityBot|ChatGPT-User|Claude-User|Perplexity-User)") { return (pass); }
Data
Only numbers per day (in the time zone of the store view), store view, crawler or assistant and page type are saved, in
the table infrangible_aitraffic, and the code of the assistant on orders; nothing about the visitors themselves.
Counting never breaks a page: database errors are only logged.
Configuration
Stores > Configuration > Infrangible Solutions > AI Traffic:
- Enable: counting per website and store view, on by default.
- Count Crawlers behind Varnish: global, off by default.
Requirements
- Magento Open Source or Adobe Commerce 2.4.6 or newer
- PHP 8.1 or newer
- Infrangible AI Visibility 1.1, installed automatically
Installation
composer require infrangible/m2-ai-traffic bin/magento module:enable Infrangible_AiVisibility Infrangible_AiTraffic bin/magento setup:upgrade bin/magento cache:flush
In production mode, also run bin/magento setup:di:compile.
License
Infrangible AI Traffic is licensed under the MIT License - see the LICENSE file for details.