Installation
Learn how to install the Insights analytics plugin for Craft CMS.
Requirements
- Craft CMS 5.0.0 or later
- PHP 8.2 or later
Craft Plugin Store
To install Insights, navigate to the Plugin Store in your Craft control panel, search for "Insights," and click Install.
Composer
ddev composer require samuelreichor/craft-insights &&
ddev craft plugin/install insights
composer require samuelreichor/craft-insights &&
php craft plugin/install insights
Add the Tracking Script
After installation, add the tracking script to your base template (usually _layouts/base.twig or similar):
{{ craft.insights.trackingScript() }}
Technically it's not important where you add the script on your page as it always injects the script at the end of the body.
That's it! Insights will now track pageviews automatically.
GeoIP Database
To enable country tracking, you need to download the free MaxMind GeoLite2-Country database:
- Create a free account at MaxMind
- Download the GeoLite2 Country database (
.mmdbformat) - Place the file at
storage/geoip/GeoLite2-Country.mmdb
Or configure a custom path in your settings:
// config/insights.php
return [
'geoIpDatabasePath' => '@storage/geoip/GeoLite2-Country.mmdb',
];
Country data is collected for all editions. Lite users who upgrade to Pro will have historical country data available. The country tracking dashboard is a Pro feature, but setting up the GeoIP database early ensures you have data when you upgrade. Without the database, country tracking is silently skipped.