This project is not covered by Drupal’s security advisory policy.
Visitor Attributes remembers how a visitor first arrived on your site: the first-touch UTM campaign, source and medium, the section they landed on, the kind of site that sent them, whether they are back after a break, and (with a geo provider) their country. You can then show content based on these values, on later pages too.
Example: a visitor who first arrives from ?utm_campaign=spring keeps seeing a spring banner on later visits, even when the URL no longer has the parameter.
Never use it for access control
Most values come from the visitor's own request. Anyone can add ?utm_campaign=partner to a link or send any Referer header. Use visitor attributes to choose what content to show, never to grant access, hide private content, skip a step or give a role.
Consent
- Nothing runs until you choose a consent mode. After installation the module captures, reads and stores nothing, and the status report shows an error.
- Nothing is stored without consent. Values are kept in one first-party cookie, set only for visitors who consent. Consent is checked on the server on every request.
- "No consent required" is the site builder's declaration and responsibility. Choose it only if your visitors don't need to give consent for this cookie.
- Values persist only for visitors who opt in. Without consent, a value is used only on the page whose own URL or referrer carries it.
- With Klaro's default settings, visitors can't opt in. Klaro's default dialog mode, Silent, shows no banner and no button. Choose another dialog mode, show Klaro's toggle button, or add a consent link. The module never changes Klaro's settings; the status report warns you instead.
The IP address is never stored. Values are limited to lists you configure: anything else is stored as "other".
Features
- Attributes: first-touch UTM source, medium and campaign; landing section; first-touch referrer (your domains, search, social, direct); returning visitor; country, continent and EU visitor; and your own query, cookie or header parameters, set up in the UI.
- A core condition per attribute, for block visibility, Context and Canvas Conditional Container.
- A cache context per attribute. Pages that use an attribute skip Internal Page Cache and vary in Dynamic Page Cache by a handful of values, not per visitor.
[visitor:*]tokens.- Capture above the page cache, plus a small script for pages served by a CDN.
- Country from a CDN header (Cloudflare, Fastly, Akamai, Acquia presets), or from other projects such as Visitor Attributes GeoIP.
- Optional placeholders, and streaming to anonymous visitors with BigPipe sessionless.
Submodules
- Visitor Attributes Klaro: lets Klaro decide whether attributes may be stored. Adds an opt-in "Visitor attributes" service.
- Visitor Attributes ECA: ECA conditions and actions, for example to copy the first-touch campaign onto a new user account.
Requirements
- Drupal 11.3 or later, or Drupal 12.
- Klaro 3.1 or later for the Klaro submodule; ECA 3.1 or later for the ECA submodule.
Getting started
composer require drupal/visitor_attributes, then install Visitor Attributes and, with Klaro, Visitor Attributes Klaro.- At Configuration › System › Visitor attributes, check the consent mode and add your allowed UTM values.
- Make sure visitors can opt in through Klaro (see above).
- Add a "Visitor: …" condition to a block, a Context or a container.
Two recipes set up working examples: Visitor Attributes Example (a banner for a spring campaign) and Visitor Attributes ECA Example (lead attribution at registration).
Hosting and caching
A page that uses an attribute isn't stored in Internal Page Cache and is sent with Cache-Control: no-cache. One visitor condition in a site-wide region turns Internal Page Cache off for every page. The README explains how to keep this to the pages that need it, and covers Pantheon and CDNs.
Status
Alpha. The public API is the visitor_attributes.profile service, the conditions, cache contexts, tokens, ECA plugins, the consent checker interface and the geo provider API. The plugin type for adding attributes in code is internal until a second module uses it; site parameters cover most needs without code.
Project information
- Project categories: Content display, User engagement
- Ecosystem: Context, ECA: Event - Condition - Action
- Created by mandclu on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
