How to Publish a Consent Banner on Your Website

Edited

Captain Compliance is published by installing a domain-specific script on your website. Each domain has its own unique script, and the correct script must be used for the site where the consent banner will appear.

This article explains where to find your Captain Compliance script, the available installation methods, and when to use each option.

Where to find your Captain Compliance script

Captain Compliance scripts are issued per domain and must be copied directly from the Captain Compliance application.

To find your script:

  1. Log in to the Captain Compliance app.

  2. Select Consent banner in the sidebar.

  3. Select the relevant domain.

  4. Under Setup, select Installation script.

  5. Copy the snippet under Script Tag Method.

The Installation Script section with the Script Tag Method snippet

The same section also provides ready-made snippets for Next.js and React applications. By default the banner chooses its language automatically. To serve one fixed language, add the language-code attribute shown in the app to the script tag, for example language-code="es".

Always confirm that the script you install matches the exact domain where it will be deployed.

The script runs only on the domain it was issued for, with or without www. On a subdomain, the banner appears only if that subdomain has been added in Captain Compliance. On any other address, such as a staging or preview address, the banner does not appear.

Installation options

You can install Captain Compliance directly on the website or through Google Tag Manager (GTM). Both methods are supported. GTM is recommended where it is available, because it also lets you control when every other tag fires.

Platform guides

For step-by-step instructions on a specific platform, see its guide. Each guide shows where the script goes on that platform and what to check afterward.

On any other platform, paste the script into the setting or template that adds code to the head of every page.

Option 1: Direct install

With a direct install, the Captain Compliance script is added directly to your site’s HTML.

Typical placement options include:

  • The global <head> section

  • A site-wide header or layout template

  • A CMS theme or template file

Pros of a direct install

  • Simple and fast to deploy

  • Fewer dependencies

  • Ideal for sites without complex tag management needs

Cons of a direct install

  • Less flexibility for advanced script orchestration

  • Changes require code or CMS access

  • No built-in preview or debug mode

Deferred mode

When using a direct install, Captain Compliance supports a deferred mode option that delays execution of the script until after the initial page load. This can help reduce performance impact and avoid timing conflicts with other scripts that load early on the page.

Deferred mode does not change consent behavior. The consent banner still appears, and consent logic still applies. The only difference is when the script runs during page load.

Deferred mode is most commonly used when:

  • The site is performance-sensitive

  • Other scripts depend on the page being fully loaded

  • You are troubleshooting script interaction or timing issues

To enable deferred mode for a direct install, add the defer attribute to the Captain Compliance script tag:

<script defer src="https://api-prod.cptn.co/banner/script?accessToken=YOUR_TOKEN"></script>

Option 2: Install using Google Tag Manager (recommended)

Installing Captain Compliance through GTM gives you more control and visibility, especially on sites with many third-party tags.

Use the Captain Compliance CMP template from the GTM Community Template Gallery. One tag loads the consent banner, sets Google Consent Mode defaults before other tags run, and honors Global Privacy Control (GPC).

  1. Add the Captain Compliance CMP template to your container.

  2. Create a tag from the template and enter the access token for the domain.

  3. Set the tag to fire on Consent Initialization - All Pages.

For the full walkthrough, see How to Install and Configure the Captain Compliance CMP Template in GTM. For an overview of how the pieces fit together, see How to Integrate Google Tag Manager (GTM) with Captain Compliance.

Note: If your container loads the script from a Custom HTML tag instead, plan a move to the template, which also sets Google Consent Mode defaults and honors GPC.

Pros of a GTM install

  • Greater control over script sequencing

  • Ability to test changes using GTM Preview mode

  • Easier coordination with analytics, marketing, and third-party tags

  • Centralized management for complex implementations

Cons of a GTM install

  • Requires GTM access and familiarity

  • Additional configuration complexity

  • Incorrect trigger selection can cause timing issues

Next steps in GTM

After the banner loads through GTM, finish the setup:

Verify the installation

After you publish the banner:

  1. Load the site in a private or incognito browser window.

  2. Confirm the consent banner appears as expected.

  3. Try Allow, Reject, and Cookie Settings.

  4. Check consent behavior in browser developer tools if needed.

For a full test plan, see How to Test Consent Banner Configuration & Behavior. If you installed through GTM, also see How to Test Your GTM Consent Setup.

Best practices

  • Keep only one Captain Compliance script active per domain.

  • Do not install the script both directly and through GTM.

  • Turn off any other cookie banner, including the one built into your website platform. Captain Compliance should be the only consent banner on the site.

  • Publish GTM changes only after testing.

  • Clear caching layers after installation.

  • If your site sends a Content Security Policy header, allow the Captain Compliance origins. See How to Configure a Content Security Policy (CSP) for Captain Compliance.

Related articles