Search by

infrangible / m2-ai-traffic

infrangible

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

Homepage

Type:magento2-module

pkg:composer/infrangible/m2-ai-traffic

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-12-03 14:26 UTC

This package is auto-updated.

Last update: 2026-12-03 14:28:09 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.txt and robots.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.