Overview
Google Tag Manager (GTM) is one of the most popular ways to manage website scripts. If your team already uses GTM for analytics and marketing tags, deploying Secure Privacy through GTM keeps everything in one place.
This guide walks you through the full setup process.
Prerequisites
Before you begin, make sure you have:
- A GTM account with an active container
- The GTM container snippet installed on your website
- Access to your Secure Privacy dashboard
Step 1: Create a Custom HTML Tag
- Open your GTM container
- Click Tags in the left sidebar
- Click New
- Select Custom HTML as the tag type
- Paste your Secure Privacy installation script into the HTML field:
<script>
var s = document.createElement("SCRIPT");
s.src = "https://app.secureprivacy.ai/script/YOUR_DOMAIN_ID.js";
s.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(s);
</script>
Replace YOUR_DOMAIN_ID with the actual ID from your Secure Privacy Installation page.
Step 2: Set the Trigger
- Click Triggering below the tag configuration
- Choose Consent Initialization - All Pages as the trigger
Using "Consent Initialization" as the trigger is critical. This ensures the Secure Privacy consent banner loads before any other tags -- including Google Analytics and advertising pixels. Using a different trigger (like "All Pages") may allow cookies to fire before the user gives consent.
Step 3: Save and Publish
- Name your tag (e.g., "Secure Privacy Script")
- Click Save
- Click Preview to test in GTM's debug mode
- Verify the consent banner appears correctly on your site
- Once confirmed, click Submit and then Publish
Tag Configuration Summary
Your completed tag should have these settings:
| Setting | Value |
|---|---|
| Tag Type | Custom HTML |
| HTML Content | Your Secure Privacy installation script |
| Trigger | Consent Initialization - All Pages |
| Tag Name | Secure Privacy Script |
Blocking Third-Party Cookies via GTM
If you add third-party scripts through GTM (e.g., Facebook Pixel, Google Ads), you may need to configure those tags to respect consent signals. This ensures cookies from those scripts are blocked when a user has not granted consent.
See the article on implementing Google Consent Mode for advanced tag control.
Troubleshooting
Banner not appearing
- Verify the script source URL is correct and matches your domain ID
- Check that the trigger is set to Consent Initialization, not "All Pages"
- Make sure no other consent management tools are installed that might conflict
Tag not firing
- Use GTM's Preview mode to inspect the tag firing order
- Confirm the container is published, not just saved in preview
- Check for JavaScript errors in the browser console (F12 > Console)
Banner appears but consent is not saved
- Verify your domain is correctly registered in the Secure Privacy dashboard
- Check that the domain in the script URL matches the page you are testing on
Next Steps
- Configure Google Consent Mode for advanced analytics and advertising compliance
- Set up cookie scanning to detect all trackers on your site
- Customize your banner design to match your brand