Setup without consent banner
This tiny, 2.8Kb (minzipped) version tracks everyone without asking permission. This is a legal risk because according to ePrivacy directive, all analytics needs a banner for European visitors. However, you might want to use this version in certain scenarios such as when you already have an existing banner system in place.
Paste this code on your website's HTML source code to get the no-banner version up and running:
You can see two configuration variables on the script tag:
The analytics token you receive after creating a new project. This is required. Tracking is disabled if there is no token.
This standard script- tag attribute ensures that the script will be fetched in parallel to parsing and evaluated as soon as it is available. That is: the script won't block the execution of the page and makes the page load faster.
Setup with the consent banner
This 3.5Kb version displays a consent banner for European visitors. ie. the banner is invisible outside Europe. This is the risk-free way to use analytics.
Here's the embed code:
Consent banner configuration
Here are all the available options:
The analytics token you receive after creating a new project. This is required.
The label of the “no” button in the consent dialog. The setting is remembered during all the page loads on a visit. Default value: “Not now”
The label of the “yes” button in the consent dialog. This setting is remembered forever. Default value: “Yes”
Whether the default CSS styling should be applied on the popup. Setting this to
false allows you to style the dialog from scratch. Defaults to
true and minimal default styling are applied. You can override the default styles with your CSS.