Drupal
Add Fluxner analytics to your Drupal site
The Fluxner module on Drupal.org adds the tracking script to every page and can pass logged-in user details to Fluxner, so you enter a Site ID instead of editing your theme. It requires Drupal 10.3 or later.
Get your tracking snippet
In your Fluxner dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:
<script src="https://fluxner.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>YOUR_SITE_ID is the numeric ID of your site. If you self-host Fluxner on another domain, replace fluxner.com with your instance's domain.
Add the snippet to Drupal
-
Install and enable the module:
composer require drupal/fluxner drush en fluxner -
Go to Configuration → Web services → Fluxner analytics (
/admin/config/services/fluxner). Your account needs the administer fluxner permission. -
Enter your Site ID and save.
Optional settings on the same page:
- Script URL: defaults to Fluxner cloud. Point it at your own instance if you self-host Fluxner.
- Visibility: restrict tracking by role or by page path, each in include or exclude mode.
- Identify logged-in users: calls
identify()with the user's UUID by default, and sends traits you define as key/value pairs.username,nameandemailare recognised trait names. - The module also exposes hooks for altering the sitewide and per-user tracking data from your own module.
If you cannot install contributed modules, copy core/modules/system/templates/html.html.twig into your theme's templates folder and add the snippet just before </head>:
<script src="https://fluxner.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
</head>Clear caches afterwards so Drupal picks up the new template.
Verify installation
Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Fluxner dashboard.
If nothing shows up:
- View the page source and search for
script.js?siteId=to confirm the snippet is on the page. - Open the browser Network tab and check that
script.jsreturns200and thatPOSTrequests go to/api/track. - Disable ad blockers, or set up a proxy so the script loads from your own domain.
- See the script troubleshooting guide for other common causes.
Troubleshooting
- Script missing after saving settings: pages are served from Drupal's page cache. Clear caches with
drush cror Configuration → Development → Performance → Clear all caches. - Visitors are tracked but you are not: check the role and path visibility settings on the module page. Excluding the administrator role is a common setup.
- Logged-in users appear anonymous: enable Identify logged-in users in the module settings; without it Drupal accounts are tracked like any other visitor.
Next steps
- Track custom events such as signups, purchases and button clicks.
- Identify users to connect sessions to accounts.
- Proxy the script through your own domain to bypass ad blockers.
- Script attributes let you skip or mask URLs and tag events.