VisitorType

Installing the snippet

The embed snippet is a ~3 kB dependency-free script. Add it to the <head>of every page, replacing the host and container id with your own (both are shown on your container's Overview tab):

<script async src="https://visitortype.ai/tms.js" data-container="AITM-XXXXXXX"></script>

What it does on each page view

1. Collects lightweight automation signals (webdriver flag, headless hints, plugin/language anomalies). 2. Makes one request to the collect API, which classifies the visitor and returns your published configuration. 3. Evaluates your triggers locally and fires matching tags. 4. Reports which tags fired.

The window.aitm API

PropertyDescription
aitm.visitorTypeThe classification, e.g. "human" or "ai_assistant"
aitm.agentNameIdentified agent, e.g. "ChatGPT-User" (or null)
aitm.dataLayerArray of events pushed by data-layer tags
aitm.firedTagsIds of tags that fired on this page view
aitm.on(\"ready\", cb)Runs cb once classification + tags are done (immediately if already ready)
window.aitm.on("ready", (a) => {
  if (a.visitorType !== "human") {
    console.log("AI visitor:", a.visitorType, a.agentName);
  }
});

Macros in tags

Tag HTML and pixel URLs support macros, replaced (URL-encoded) at fire time: {{visitor_type}}, {{agent_name}}, {{agent_category}}, {{page_path}}, {{page_url}}.

The snippet fails open: if the API is unreachable, your page is untouched and aitm.ready still becomes true. A broken tag never breaks the page or other tags.

Testing your install

Open your site with the browser console: window.aitm should be defined and visitorTypeset after load. Then check the container's Analytics tab — your visit appears with source snippet. To simulate an AI crawler, see the API reference.