Installing the cookie bar with the text/plain method
You leave the scripts where they are, change the type of each one to text/plain and add its consent category. The bar then runs them only when the visitor allows that category. This is the smallest change to the website's structure. Google tags marked this way run in the basic mode of Consent Mode.
Google tags marked text/plain run in the basic mode of Consent Mode. They do not load at all before consent, so they send no data to Google, not even anonymous cookieless measurements. Google then uses a general model for conversion modeling. If you want advanced mode, where Google tags load straight away and work with denied values until consent is given, leave the Google tag unmarked below the bar script or use Google Tag Manager. The difference is described in Basic and advanced mode.
When to choose this method
- Your scripts are built into templates or components and you do not want to move them.
- You need the smallest possible change to the website's structure.
- You want to see directly in the code which category runs which script.
What you will need
- Access to the website templates, that is the ability to edit
<head>and individual scripts. - A list of all third-party scripts, such as GA4, Google Ads, Meta, LinkedIn, Hotjar, Heureka and others.
- A split of these scripts into categories, which must match the bar's configuration.
1. Inserting the bar script
Insert the script as the first script in the <head>, above the other scripts including Google Tag Manager and gtag.js, and without async and defer. You can copy the ready-made code from the license's Implementation tab:
<script src="https://cookies-spravne.cz/static/cc_v2?key=YOUR_LICENSE_KEY"></script>2. Marking the scripts
For every script that must not run without consent, set type="text/plain" and add the data-cookiecategory attribute with the category name.
Scripts are assigned to the necessary, analytics and marketing categories. The name in data-cookiecategory must match them exactly, including upper and lower case. A different name, such as advertising, means the script never runs.
GA4 and other analytics
<script type="text/plain" data-cookiecategory="analytics"
src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script type="text/plain" data-cookiecategory="analytics">
// original GA4 configuration
</script>Google Ads, Meta and other advertising
<script type="text/plain" data-cookiecategory="marketing">
// remarketing and conversion tags
</script>Mark other services such as Hotjar, LinkedIn or Sklik the same way, just with the right category. Analytics belongs in analytics, advertising and remarketing in marketing. The necessary category always runs; only what the website cannot work without belongs there.
The bar runs marked scripts in the order they appear on the page. A script with src loads before the next one gets its turn, so it is enough to keep a library and its configuration one after the other and mark them with the same category. The bar always runs them only after it has sent the consent update for Google Consent Mode.
If you add marked scripts to the website after the page has loaded (single-page applications, Turbo and similar), call cookieconsent.updateScripts() after inserting them. The bar then runs them according to the current consent.
3. Testing
- Open the website in a private window and do not give consent. The bar must appear, marked scripts must not run and iframes must be blocked.
- Give consent and check that the scripts from the allowed categories have run.
- Withdraw consent with the Cookie settings link in the footer and check that the relevant scripts no longer run.
- In DevTools, on the Application → Cookies and Network tabs, check that cookies and requests appear only after consent.
- On the license's Overview tab, run the installation check.