Key takeaways
- A banner alone does not stop tracking: scripts must actually be held back until consent.
- Load the consent script first in the <head>, without async or defer, so it runs before anything it needs to hold back.
- Known trackers are held back automatically; add rules for others, or tag scripts by hand for the strictest result.
- Test in a private window with ?pgcmp_debug=1 to see what is held back and released.
Step 1: put the consent script first
Paste your install tag as the very first tag inside <head>. Do not add async or defer: the script must run before the others so it can hold them back.
<head>
<script id="pgcmp" src="https://cdn.trustedcookie.io/c/YOUR_SITE_KEY/script.js"></script>
<!-- analytics, ads and chat scripts after it -->
</head>Step 2: let known trackers be blocked automatically
About 25 common vendors, including Google Analytics, Meta Pixel and Hotjar, are recognised by their address and held back until their category is allowed. You can switch any of them off under Cookie Manager, Scripts.
Step 3: add rules for everything else
Under Cookie Manager, Scripts, add an address pattern such as cdn.example-chat.com and choose its category. Scripts added by other scripts are then never requested before consent. Scripts written directly in your HTML may be downloaded by the browser, but they do not run.
Step 4: tag scripts by hand for zero requests
For the strictest result, change the script's type and add a category. The browser then makes no request at all until consent:
<!-- before -->
<script src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>
<!-- after: runs only once Analytics is allowed -->
<script type="text/plain" data-pgcmp-category="analytics"
src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>This works for inline scripts too. Use functional, analytics or marketing as the category.
Step 5: test it
- Open your site in a private window. The banner shows.
- Add ?pgcmp_debug=1 to the address and open the browser console: it lists what the script holds back and releases.
- In the Network tab, check that analytics and ad requests only appear after you accept.
- Make a choice, then check that the record appears in your consent log within a few seconds.
Questions
What about scripts from my own domain?
Copies of scripts served from your own domain, for example by a caching plugin, are not matched by address. Leave the original address out of the plugin's minify, combine and delay lists, or tag the script by hand.
What happens when a visitor withdraws consent?
The page reloads and the cookies on your cookie list for that category are deleted, so the scripts stop.