Download Consenty from Github and add it to the head of your website:
Consenty will inject a <div> right before your <template> - you can make it use a <span> instead by adding consenty-tag="span" to your element.
The example above has one caveat: If you put a script-tag inside one of the <span>-tags that script would either immediately get executed or if using a src-attribute load the script from the given source. The idea of consenty is to prevent this, so you can simply use the <template>-tag instead:
The basic concept is as follows:
And then some custom JS to do different things based on consent:
Finally we need to handle clicks on buttons in the consent modal:
Lorem Ipsum
Please check the console of your browser dev tools!
When using page transition libraries like barba.js you need to send pageviews manually to your tracking software. If the user revoke consent you are not allowed to do so!