Configure Osano cookie consent with Google Tag Manager using our straightforward guide. Follow easy steps for Direct Install or set up Osano through Google Tag Manager. Osano's cookie consent works with any platform, ensuring smooth operation without additional configurations.
When using Osano CMP together with Google Tag Manager, you have 2 options for how to install the osano.js script.
**Direct install (recommended)**: place osano.js first in the <head> tag of your page so that it loads before Google Tag Manager
**Install via Google Tag Manager (not recommended)**: Use Google tag manager to manage your osano.js tag.
Please be aware that in order for Osano's obligations under the “No fines, No penalties” Guarantee to apply, you must use the Direct Install method (in accordance with the documentation on this page) and be on the most up-to-date version of Osano CMP.
Before you can install osano.js, you must first generate the script by creating and publishing a CMP configuration. Navigate to the "Consent Management" tab in my.osano.com and create a new Consent Configuration.
You’ll need to provide your site’s domain name (e.g., example.com) and a URL to your privacy policy. Additional configuration is available after the initial creation.
Click the Create Configuration button.
Publish your new configuration by clicking the Publish button.
Once published, use the "Get Code" button to copy the osano.js script tag.
Osano.js can work on any platform and with any script manager or loader when added directly to the <head> element of a website. This means that Osano will work without having to do any additional configuration within Google Tag Manager or other script management solutions if you choose this install method.
To install, simply copy and paste the osano.js code snippet into the header <head> for all pages you wish to monitor. Ensure that osano.js is the first script that loads on your site. If possible, we recommend testing in a staging/pre-production environment.
Note: If your pre-production environment has different tags than your production environment, it will be beneficial to test in "Permissive" mode before switching to "Strict".
While it is possible to load osano.js via Google Tag Manager, we strongly recommend loading it outside of Google Tag Manager in the site <head>. If you must implement osano.js via Google Tag Manager, then all non-essential scripts, cookies, and iframes must also be implemented and classified through Google Tag Manager, and you will need to follow the steps below. Any resources loaded outside of Google Tag Manager (directly on the page, for instance) will be able to load before osano.js can intercept them.
Important note: scripts, cookies, and iframes that are not managed by Google Tag Manager will not be reported by osano.js in my.osano.com.
Add osano.js using our community template and set it up to trigger before all other scripts.
In Google Tag Manager under Tags, add a new tag.
Name it “Osano CMP”
When choosing a tag type, select the option to discover or browse tags in the Community Template Gallery. Search for “osano”.
Google Tag Manager will show you what permissions the template requires to operate correctly. Review and then add the template to your workspace.
The tag configuration will require that you provide your Osano customer ID and configuration ID. These can be found in the “Get Code” dialog within your consent configuration:
In the trigger field, select “Consent Initialization - All Pages”. This step is critical to correctly implement functionality.
Save the new tag.
This trigger will fire when osano.js has loaded and is ready to evaluate scripts for consent compliance.
In Tag Manager under Triggers, add a new trigger.
Name your trigger “Osano CMP ready”.
For trigger type, choose “Custom Event”.
For the event name, use this exactly: osano\\cm--load-.+
Check the option to use regex matching.
Select the option to fire the trigger on all custom events.[See image: Cookie Consent - GTM Trigger]
Save the trigger.
For every tag in your Google Tag Manager workspace (other than Osano CMP), set the trigger to be the one you created in step 2.
Open the tag.
Remove any existing trigger.
Set the new trigger to be “Osano CMP ready”.
Ensure that osano.js is the first script that loads on your site.
It is not required to enable the Google Consent Mode setting in your configuration when implementing osano.js through our Osano community template. For more information on when this setting is required, please see Osano and Google Consent Mode.
You can also set up consent listeners in a custom tag by hooking into Osano’s public API (linked).
Create a new "Custom HTML" tag
Use window.Osano.cm.addEventListener to add your own custom events to the dataLayer and listen for osano-cm-initialized. Once initialized, all subsequent tags can be triggered.
Q: Can I leave Google Tag Manager classified as Essential and still have granular control over the tags inside it?
A: Yes. It often makes sense to let the GTM container load as Essential while classifying the individual Google and third-party resources it loads more restrictively.
The key distinction is between GTM as the container/loader and the tracking or advertising technologies that execute through it. Keeping the container Essential lets it initialize and manage downstream tags and consent logic, while the individual resources it loads can be classified according to their actual purpose.
Example:
Essential - GTM container
https://www.googletagmanager.com/gtm.js?id=GTM-xXXXXXXNon-Essential - Google measurement and advertising resources
https://www.googletagmanager.com/gtag/js?id=G-xXXXXXX
https://www.googletagmanager.com/gtag/destination?id=AW-xXXXXXXXX
https://www.googletagmanager.com/td?id=AW-xXXXXXXXXgtag/js (G- prefixed) ties to Google Analytics, typically classified as Analytics. gtag/destination and /td (AW- prefixed) tie to Google Ads, typically classified as Marketing.
Q: Why classify gtag as non-essential?
A: These resources participate directly in analytics, conversion measurement, or advertising, unlike the container itself. Classifying them separately keeps GTM available for site and consent logic while blocking Google Analytics or advertising resources until consent exists.
One caveat: classifying GTM as Essential means the container can run before consent, so any tags or requests it initiates still need to be controlled via Osano classifications, GTM consent requirements, triggers, or Google Consent Mode. If your requirement is zero Google-related requests before consent, classify the GTM container itself as non-essential instead.
The right approach depends on whether your priority is keeping GTM available as infrastructure or blocking all GTM-driven activity until consent is granted.