---
title: "Context Types"
manual: "Multi-channel Contexts"
version: "5.1"
permalink: "https://docs.typo3.org/permalink/netresearch/contexts:context-types@5.1"
source: "ContextTypes/Index.rst"
rendered: "2026-11-09T07:35:56+00:00"
---

# Context Types {#context-types}

The extension provides several built-in context types. Each type evaluates
different conditions to determine if a context is active.

**On this page**

-   [IP Address Context](https://docs.typo3.org/permalink/netresearch/contexts:ip-address-context@5.1)
-   [Domain Context](https://docs.typo3.org/permalink/netresearch/contexts:domain-context@5.1)
-   [Query Parameter Context](https://docs.typo3.org/permalink/netresearch/contexts:query-parameter-context@5.1)
-   [HTTP Header Context](https://docs.typo3.org/permalink/netresearch/contexts:http-header-context@5.1)
-   [AI crawler context](https://docs.typo3.org/permalink/netresearch/contexts:ai-crawler-context@5.1)
-   [Session Context](https://docs.typo3.org/permalink/netresearch/contexts:session-context@5.1)
-   [Combination Context](https://docs.typo3.org/permalink/netresearch/contexts:combination-context@5.1)
-   [Related Extensions](https://docs.typo3.org/permalink/netresearch/contexts:related-extensions@5.1)

## IP Address Context {#context-type-ip}

Match visitors by their IP address or IP range. Supports both IPv4 and IPv6.

### Configuration {#configuration}

-   **IP/Range**

    -   *type:* string
    -   *required:* true

    Single IP address, CIDR notation, range, or comma-separated list.

Examples:

-   Single IP: `192.168.1.100`
-   CIDR notation: `10.0.0.0/8`, `FE80::/16`
-   Range: `192.168.1.1-192.168.1.255`
-   Wildcards: `80.76.201.*`, `80.76.*.37`
-   Multiple: `192.168.1.0/24,10.0.0.0/8`

### Use Cases {#use-cases}

-   Internal network detection (show admin tools for office IPs)
-   Geographic content (by IP geolocation with `contexts_geolocation`)
-   Office vs. external visitor differentiation
-   Development/staging environment detection

## Domain Context {#context-type-domain}

Match based on the accessed domain name (HTTP_HOST).

### Configuration {#configuration-1}

-   **Domain**

    -   *type:* string
    -   *required:* true

    Domain name(s) to match. One domain per line.

**Matching Rules:**

-   Without leading dot: Exact match only

    -   `www.example.org` will **not** match `example.org`
-   With leading dot: Matches all subdomains

    -   `.example.org` matches `www.example.org`, `shop.example.org`, etc.

Examples:

-   Single: `www.example.com`
-   Multiple (one per line):

    ```
    example.com
    www.example.com
    ```
-   Subdomain wildcard: `.example.com`

### Use Cases {#use-cases-1}

-   Multi-domain setups (different content per domain)
-   Staging vs. production detection
-   Brand-specific content on shared installations
-   Language-specific domains

## Query Parameter Context {#context-type-getparam}

Match based on URL query parameters (GET parameters).

### Configuration {#configuration-2}

-   **Parameter Name**

    -   *type:* string
    -   *required:* true

    The GET parameter name to check.

-   **Expected Value**

    -   *type:* string
    -   *required:* false

    Value to match. Supports regular expressions. If empty, any non-empty
    value activates the context.

-   **Store in Session**

    -   *type:* boolean
    -   *default:* true

    When enabled, the context state is stored in the user session, persisting
    across page navigations even after the parameter is removed from the URL.

Examples:

-   `?debug=1` with parameter `debug` and value `1`
-   `?variant=a` for A/B testing
-   `?affID=partner` for affiliate tracking

### Use Cases {#use-cases-2}

-   A/B testing variants
-   Debug mode activation
-   Campaign and affiliate tracking
-   Feature flags via URL

## HTTP Header Context {#context-type-httpheader}

<!-- TODO: no Markdown rendering for "versionadded" -->

HTTP Header context for matching request headers.

Match based on HTTP request headers sent by the browser or proxy.

### Configuration {#configuration-3}

-   **Header Name**

    -   *type:* string
    -   *required:* true

    The HTTP header name to check (case-insensitive).

-   **Expected Value**

    -   *type:* string
    -   *required:* false

    Value(s) to match against the header. One value per line.
    Matching uses **case-insensitive substring** comparison: if any
    configured value appears anywhere in the actual header value,
    the context matches. If empty, any non-empty header value
    activates the context.

-   **Store in Session**

    -   *type:* boolean
    -   *default:* true

    Has no effect for this context type. The header is evaluated on every
    request, so the context is active only on requests that carry a matching
    header.

<!-- TODO: no Markdown rendering for "versionadded" -->

PSR-7 header support and case-insensitive substring matching.

#### Header Name Resolution {#header-name-resolution}

The extension supports both standard HTTP header names and
`$_SERVER` parameter keys:

-   **PSR-7 header names** (recommended): `User-Agent`,
    `Accept-Language`, `X-Forwarded-For`
-   **$\_SERVER keys** (legacy): `HTTP_USER_AGENT`,
    `HTTP_ACCEPT_LANGUAGE`

The lookup order is:

1.  PSR-7 `$request->getHeaderLine()` (standard header name)
1.  `$request->getServerParams()` (`$_SERVER` key format)

#### Value Matching {#value-matching}

Values are matched using **case-insensitive substring** comparison.
For example, with header `User-Agent` and configured values:

```
Mobile
Android
iPhone

```

A User-Agent string like `Mozilla/5.0 (iPhone; CPU iPhone OS)`
matches because it contains `iPhone` (case-insensitive).

Examples:

-   `X-Forwarded-For` for proxy detection
-   `Accept-Language` for language preferences
-   `User-Agent` for browser/device detection
-   Custom headers from CDN or load balancer

### Use Cases {#use-cases-3}

-   CDN or proxy detection (`X-Forwarded-For`, `CF-Connecting-IP`)
-   Mobile device detection via `User-Agent`
-   Accept-Language based content
-   Custom application headers
-   Bot detection; for AI crawlers use the [AI crawler context](https://docs.typo3.org/permalink/netresearch/contexts:context-type-aicrawler@5.1)

## AI crawler context {#context-type-aicrawler}

Matches requests whose `User-Agent` header names a known AI crawler or AI
fetcher. Editors select the type and need no user-agent strings; the list of
crawlers ships with the extension. Use the context like any other, for
example to show or hide pages and content elements.

### Configuration {#configuration-4}

-   **Additional user-agent substrings**

    -   *type:* string
    -   *required:* false

    Further substrings, one per line, for crawlers that are not on the
    built-in list. Matching is the same as for the HTTP header context:
    case-insensitive substring comparison against the `User-Agent` header.

-   **Store in Session**

    -   *type:* boolean
    -   *default:* true

    Has no effect for this context type. The header is evaluated on every
    request.

### Built-in user agents {#built-in-user-agents}

Each entry is the name its vendor documents for its crawler or fetcher.
OpenAI and Perplexity publish the full user-agent strings; Anthropic
publishes the bot names. Last checked against the sources on 2026-11-06.

| User agent | Vendor's stated purpose | Source |
| --- | --- | --- |
| `GPTBot` | Crawls content that may be used to train OpenAI's foundation models | [OpenAI crawlers](https://developers.openai.com/api/docs/bots) |
| `OAI-SearchBot` | Indexes sites for ChatGPT search | [OpenAI crawlers](https://developers.openai.com/api/docs/bots) |
| `ChatGPT-User` | Visits a page for a user action in ChatGPT | [OpenAI crawlers](https://developers.openai.com/api/docs/bots) |
| `ClaudeBot` | Collects content that may be used to train Anthropic's models | [Anthropic crawlers](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler) |
| `Claude-SearchBot` | Indexes content to improve search answers | [Anthropic crawlers](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler) |
| `Claude-User` | Fetches a page when a user asks Claude a question | [Anthropic crawlers](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler) |
| `PerplexityBot` | Surfaces and links websites in Perplexity search results | [Perplexity crawlers](https://docs.perplexity.ai/guides/bots) |
| `Perplexity-User` | Visits a page when a user asks Perplexity a question | [Perplexity crawlers](https://docs.perplexity.ai/guides/bots) |

Not on the list:

-   `Google-Extended` is a robots.txt product token only. Google states that
    it has no separate HTTP user-agent string, so it cannot be detected in a
    request.
-   `anthropic-ai` does not appear in Anthropic's documentation.
-   `OAI-AdsBot` checks the landing pages of ChatGPT ads; it does not read
    content for training, search or users.

### Extending the list {#extending-the-list}

Integrators add user agents for all AI crawler contexts of an installation
in [`config/system/additional.php`](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/Index.html#file-project-config-system-additional-php) or an extension's
[`ext_localconf.php`](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtLocalconf.html#file-extension-ext-localconf-php):

```php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['contexts']['aiCrawlerUserAgents'][] = 'ExampleAiBot';
```

Entries that are not non-empty strings are ignored. To add a user agent for
one context only, use [Additional user-agent substrings](https://docs.typo3.org/permalink/netresearch/contexts:confval-aicrawler-additional-user-agents@5.1).

> [!WARNING]
> The `User-Agent` header is set by the client. The context detects what
> a client claims to be and does not verify it: a browser can send
> `GPTBot` and a crawler can send a browser user agent. Do not use the
> context to protect content.

## Session Context {#context-type-session}

Match based on frontend user session data.

### Configuration {#configuration-5}

-   **Session Key**

    -   *type:* string
    -   *required:* true

    Key in the session data to check.

-   **Expected Value**

    -   *type:* string
    -   *required:* false

    Value to match. If empty, checks if the key exists and is not NULL.

### Use Cases {#use-cases-4}

-   User state tracking
-   Shopping cart state (cart has items)
-   Login/authentication state
-   Multi-step form progress
-   User preference flags

## Combination Context {#context-type-combination}

Combine multiple contexts with logical operators for complex rules.

### Configuration {#configuration-6}

-   **Expression**

    -   *type:* string
    -   *required:* true

    Logical expression combining context aliases.

**Operators:**

-   `&&` \- logical AND (all must match)
-   `||` \- logical OR (any must match)
-   `!` \- negation (must NOT match)
-   `(...)` \- parentheses for grouping

Examples:

-   `mobile && !tablet` \- Mobile but not tablet
-   `internal || admin` \- Internal network or admin user
-   `(german || austrian) && !guest` \- German-speaking non-guest
-   `campaign_a && !already_converted` \- Campaign A visitors who haven't converted

### Use Cases {#use-cases-5}

-   Complex multi-condition business rules
-   Nested context hierarchies
-   Exclusion rules (show to A but not if B)
-   Compound targeting (A AND B OR C)

> [!TIP]
> Use descriptive context aliases to make combination expressions readable.
> For example: `premium_user && active_campaign && !opted_out`

## Related Extensions {#related-extensions}

Additional context types are available through companion extensions:

-   **contexts_geolocation**

    Location-based contexts using IP geolocation:

    -   Continent detection
    -   Country detection
    -   Area/region detection

-   **contexts_wurfl**

    Device-based contexts using WURFL database:

    -   Device type (phone, tablet, TV, desktop)
    -   Screen size detection
    -   Browser capabilities
