Tag Managers
Google Tag Manager
Deploy UCAPTCHA through GTM without touching your site's code â and optionally limit it to fire only on specific pages, like your contact page.
Part 1 â Create the UCAPTCHA tag
Open Google Tag Manager
Go to tagmanager.google.com and open the workspace for the website you want to protect.
Add a new tag
- In the left sidebar, click Tags
- Click New in the top right
- Click Tag Configuration to choose a tag type
- Scroll down and select Custom HTML
Paste the UCAPTCHA snippet
In the HTML field, paste the following. Replace YOUR_SITE_KEY with your actual UCAPTCHA site key.
<script>
window.UCAPTCHA_SITE_KEY = 'YOUR_SITE_KEY';
(function() {
var s = document.createElement('script');
s.src = 'https://www.ucaptcha.site/captcha-widget.js';
document.head.appendChild(s);
})();
</script>data-* attributes from custom HTML tags, which is why we use window.UCAPTCHA_SITE_KEY instead of a data-site-key attribute. UCAPTCHA automatically looks for this global variable as a fallback.Name the tag
Click the pencil icon in the top left and give your tag a descriptive name, such as UCAPTCHA â All Forms or UCAPTCHA â Contact Page.
Part 2 â Set up a trigger
A trigger tells GTM when to fire your tag. You have two options: fire on every page, or fire only on specific pages like your contact page.
Option A â Fire on all pages
Use this if you have forms on multiple pages and want UCAPTCHA to protect all of them.
- In the tag editor, click Triggering
- Click the + button to add a trigger
- Select All Pages (this is a built-in trigger)
- Click Add
Option B â Fire only on your contact page
Use this if you only want UCAPTCHA on a specific page â for example, /contact. This is more efficient and avoids loading the widget on pages that don't have forms.
Step 1 â Create a new trigger
- Click Triggering in the tag editor
- Click the + button, then click + again in the top right to create a new trigger
- Click Trigger Configuration
- Select Page View as the trigger type
Step 2 â Configure the page condition
- Under This trigger fires on, select Some Page Views
- In the condition row, set the three fields as follows:
| Field | Operator | Value |
|---|---|---|
Page URL | contains | /contact |
âĸ
contains /contact â matches example.com/contact and example.com/contact-usâĸ
equals https://example.com/contact â matches only that exact URLâĸ
matches RegEx /contact|get-in-touch â matches either pageStep 3 â Save the trigger
- Give the trigger a name like Contact Page
- Click Save
- You'll be taken back to the tag editor with the new trigger applied
Part 3 â Publish your changes
Save the tag
Click Save in the tag editor to save your tag and trigger configuration.
Preview and test
- Click Preview in the top right of GTM
- Enter your website URL and click Connect
- GTM will open your site in a new tab with the Tag Assistant panel
- Navigate to your contact page and confirm the UCAPTCHA tag appears under Tags Fired
- You should see the UCAPTCHA checkbox inside your contact form
Submit and publish
- Close the preview and click Submit in the top right of GTM
- Add a version name like Add UCAPTCHA and click Publish
Protecting multiple specific pages
If you want UCAPTCHA on several pages but not all of them, you have two options:
Add multiple conditions to one trigger
In the trigger configuration, click + to add more conditions and set the logic to OR:
| Field | Operator | Value |
|---|---|---|
Page URL | contains | /contact |
Page URL | contains | /get-a-quote |
Page URL | contains | /newsletter |
Use a RegEx condition
For a cleaner setup, use a single RegEx condition:
| Field | Operator | Value |
|---|---|---|
Page URL | matches RegEx | /contact|get-a-quote|newsletter |
Other installation guides