Install Statsdot on Drupal
Updated October 18, 2026
Without code: Asset Injector
- Install and enable the Asset Injector module.
- Go to Configuration > Development > Asset Injector > JS Injector and add an injector.
- The injector takes JavaScript code, not an HTML tag, and Statsdot needs its
data-domainattribute. Paste this code, which adds the tag with the attribute:
(function () {
var s = document.createElement('script');
s.defer = true;
s.src = 'https://statsdot.com/js/script.js';
s.setAttribute('data-domain', 'yoursite.com');
document.head.appendChild(s);
})();
- Under the conditions, leave out administration pages (for example with the theme condition set to your front-end theme), then save.
In your theme
If you maintain your own theme or subtheme, add the tag to templates/html.html.twig (copy it from the base theme if your theme does not have it), inside <head>:
<script defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>
Clear the cache under Configuration > Development > Performance to see the change.
Track events with data-statsdot-event="Contact" on a link, button or form. See Events and goals.