gacsp provides flexible Google Analytics integration in Drupal that is easily extensible by other modules.
No inline Javascript is used, to not inhibit the use of CSP (Content Security Policy) for the prevention of XSS attacks.
The default module configuration allows specifying a Google Analytics Tracking ID, and optionally enabling additional plugins.
Each of the default options can be individually disabled if custom behaviour is provided by another module, or all default behaviour can be disabled completely.
To add additional commands, create an Event Subscriber for the
\Drupal\gacsp\AnalyticsEvents::COLLECT
event. The subscriber will be sent an
instance of \Drupal\gacsp\Event\CollectEvent
.
The gacsp.command_registry
service is available as a convenience for adding
commands within procedural code.
Each command has a priority that determines the order that it is added to the command queue. The default values are
- Create: 300
- Require: 250
- Set: 100
- Generic: 0
- Pageview: -5
- Send, Event: -10
If a set of commands need to maintain a consistent order among other commands,
add them within a \Drupal\gacsp\AnalyticsCommand\Group
instance with the
appropriate priority.