I recently had to start implementing websites with Matomo Tag Manager, and had to combine it with orestbida/cookieconsent, a concent banner I really like!
So here was my strategy:
- Create your banner on their playground
- create the Matomo Tag Manager container
- Add a HTML Tag where I include the code from cookieconsent-config.js, wrapped in
<style>...</style>
- Integrate the MTM container in the website.
- Add a script that pushes an event to the MTM data layer
window.addEventListener('cc:onConsent', ({detail}) => {
_mtm.push({"event": "marketing-concent-given"});
});
- And on that event load the according scripts.
(I'll expand it with more detail a bit later)