Visitors (Web Analytics)

A powerful, native Drupal web analytics tool that records and displays comprehensive site visitor history without external dependencies.

visitors
5,763 sites
66
drupal.org

Install

Drupal 11, 10 v8.x-2.32
composer require 'drupal/visitors:8.x-2.32'

Overview

Visitors is a comprehensive web analytics solution built natively for Drupal. It provides site administrators with detailed insights into user behavior, site performance, and traffic patterns without relying on external services like Google Analytics.

The module tracks page views, sessions, user engagement, device information, geographic location, referrer data, and browser capabilities. It offers extensive reporting through Views-based dashboards covering visits, behavior, acquisition, and performance metrics. Reports can be filtered by date range and include visualizations powered by the Charts module.

Key capabilities include entity view counters, bot detection, spam referrer blocking, search engine traffic identification, social network referrer tracking, and AI assistant bot detection. Privacy controls allow users to opt-in or opt-out of tracking based on permissions.

Features

  • Tracks all site visits with comprehensive data collection including page views, user sessions, timestamps, and performance metrics
  • Provides geographic location tracking (continent, country, region, city) with optional MaxMind integration for enhanced accuracy
  • Detects and records device information including device type, brand, model, screen resolution, and browser capabilities
  • Identifies browser software including browser name, version, engine, operating system, and installed plugins (Flash, Java, PDF, etc.)
  • Tracks user engagement metrics including session duration, page views per visit, bounce rate, and returning visitor status
  • Records referrer information with automatic classification of search engines (200+), social networks (150+), and AI assistants
  • Includes spam referrer blocking with a pre-loaded database of 2,300+ spam domains
  • Provides entity view counters for nodes and other content entity types with today's views, total views, and last view timestamp
  • Offers extensive Views integration with 50+ custom fields, filters, and sorts for building custom reports
  • Displays performance reports showing network, server, transfer, DOM processing, and total page load times
  • Supports condition-based visibility to control tracking by path, user role, or other Drupal conditions
  • Allows per-user opt-in/opt-out of tracking based on configurable permissions
  • Provides automatic log retention with configurable cleanup for both regular visits and bot traffic
  • Includes Drush command for migrating data from previous module versions

Use Cases

Privacy-Compliant Web Analytics

Use Visitors as a GDPR-friendly alternative to Google Analytics. All data is stored locally on your server with no third-party tracking. Configure user opt-out settings and data retention policies to comply with privacy regulations.

Content Performance Monitoring

Track which pages and content items receive the most traffic. Use the Popular Content block to showcase trending content on your homepage. Analyze entry and exit pages to optimize content flow.

Audience Analysis

Understand your audience through geographic, device, and software reports. Identify which countries, browsers, and devices your visitors use to optimize the site experience accordingly.

Bot Traffic Monitoring

Track AI assistant bots (ChatGPT, Claude, etc.) and search engine crawlers visiting your site. Configure separate retention policies for bot traffic to manage database size while maintaining human visitor data.

Performance Optimization

Monitor page load performance metrics including network time, server response, DOM processing, and total load times. Identify performance bottlenecks by analyzing hourly, daily, and weekly performance trends.

Marketing Campaign Analysis

Track traffic from social networks (150+ platforms) and search engines (200+ supported). Analyze referrer data to understand which marketing channels drive the most engagement.

Spam Protection

The module includes a database of 2,300+ known spam referrer domains that are automatically filtered from your analytics, ensuring clean and accurate traffic data.

User Engagement Tracking

Analyze user engagement through metrics like session duration, pages per visit, bounce rate, returning visitor rates, and time between visits. Use this data to improve content strategy.

Tips

  • Set up appropriate log retention policies early to prevent database bloat - 13 months is recommended for year-over-year comparisons.
  • Use the 'Do not log' option for bot retention if you don't need to analyze bot traffic, significantly reducing database size.
  • Configure visibility conditions to exclude admin paths and authenticated user visits for cleaner public traffic data.
  • Install the MaxMind module for accurate geographic data - without it, location tracking is limited.
  • Use the Views integration to create custom reports and embed visitor statistics in dashboards.
  • Grant 'Access visitors' permission carefully - reports may contain sensitive user behavior data.
  • The Popular Content block is a great way to showcase trending content and increase engagement.
  • Use entity tokens like [node:total-count] in content to display view counts dynamically.

Technical Details

Admin Pages 17
Visitor Settings /admin/config/system/visitors

Configure all aspects of the Visitors module including tracking behavior, log retention, entity counters, and visibility conditions.

Visitors /admin/visitors

Main dashboard providing access to all visitor analytics reports organized into Visits, Behavior, and Acquisition categories.

Logs /admin/visitors/visit/hits

View recent page visits with details including timestamp, path, referrer, user, and session information. Includes date range filtering.

Locations /admin/visitors/visit/location

Geographic distribution of visitors showing continents, countries, regions, cities, and browser languages with drill-down capability.

Devices /admin/visitors/visit/device

Device analytics including device types (desktop, mobile, tablet), brands, models, and screen resolutions.

Software /admin/visitors/visit/software

Browser and operating system statistics including OS versions, browser versions, browser engines, device configurations, and browser plugins.

Times /admin/visitors/visit/times

Time-based analytics showing visits by hour (server and local time), day of week, day of month, and monthly trends.

Users /admin/visitors/visit/users

User-specific analytics showing registered user activity and visit patterns.

Hosts /admin/visitors/behavior/host

View page count statistics grouped by hostname/domain.

Pages /admin/visitors/behavior/path

Most frequently visited pages/paths on the site with hit counts and percentage distribution.

Entry Pages /admin/visitors/behavior/path-entry

Landing pages where visitors first enter the site, showing entry frequency and trends.

Exit Pages /admin/visitors/behavior/path-exit

Exit pages where visitors leave the site, helping identify potential problem areas.

Engagement /admin/visitors/behavior/engagement

Engagement metrics including visit duration distribution, pages per visit, visit frequency, and time since last visit.

Performance /admin/visitors/behavior/performance

Page load performance metrics including network time, server time, transfer time, DOM processing, and total load time. Available in weekly, daily, and hourly views.

AI Assistants /admin/visitors/acquisition/ai

Traffic from AI assistants and bots including ChatGPT, Claude, Gemini, Copilot, Perplexity, and others.

Social Networks /admin/visitors/acquisition/social

Traffic from social networks including Facebook, Twitter, LinkedIn, Instagram, TikTok, and 150+ other platforms.

Visitors (Node Tab) /node/{node}/visitors

Node-specific visitor analytics showing traffic and referrers for individual content items.

Permissions 3
Access visitors

Allows users to access all visitor reports and analytics pages.

Opt-in or out of tracking

Allows users to control whether their visits are tracked via their account settings.

View content hits

Allows users to see the view count displayed on content items.

Hooks 9
hook_cron

Executes scheduled cleanup of old visitor logs based on configured retention periods.

hook_page_attachments

Attaches the tracking JavaScript library to pages when tracking is enabled and visibility conditions are met.

hook_form_user_form_alter

Adds opt-in/opt-out tracking settings to user account forms for users with the appropriate permission.

hook_node_links_alter

Displays view count on node content for users with 'view visitors counter' permission.

hook_entity_delete

Cleans up visitor counter data when entities are deleted.

hook_ranking

Provides view count as a ranking factor for search results.

hook_views_data

Exposes visitor data tables to Views with extensive field, filter, sort, and relationship definitions.

hook_token_info

Provides tokens for entity view statistics (total-count, day-count, last-view).

hook_tokens

Generates replacement values for visitor statistic tokens.

Drush Commands 1
drush visitors:upgrade

Upgrades data from the 8.x-2.x version to the 3.0.x data structure. Migrates visit records from the old table format to the new visits/events architecture.

Troubleshooting 5
Tracking is not recording any visits

Verify that tracking is enabled at /admin/config/system/visitors. Check visibility conditions to ensure your paths and roles are not excluded. Verify that cron is running for the tracking endpoint to be accessible.

Geographic location data is missing

Install and configure the MaxMind module for accurate geolocation. Without it, location data relies on browser language and may be limited.

Database growing too large

Configure log retention settings at /admin/config/system/visitors. Set appropriate retention periods for both regular visits and bot traffic. Ensure cron is running regularly to clean up old records.

Charts not displaying in reports

Ensure the Charts module is installed with the Chart.js submodule (charts_chartjs) enabled. Clear the Drupal cache after installation.

View counts not appearing on content

Enable 'Count entity views' in settings and ensure 'node' is selected in Entity Types. Grant the 'View content hits' permission to appropriate roles.

Security Notes 5
  • All tracking data is stored locally in your Drupal database - no data is sent to third parties.
  • User IP addresses are logged - consider privacy implications and configure appropriate retention periods.
  • The 'Access visitors' permission grants access to detailed user behavior data - assign carefully.
  • Enable user opt-out functionality to comply with privacy regulations like GDPR.
  • Spam referrer blocking helps protect against referrer spam attacks that could pollute your analytics.