Docs / Google Tag Manager
Google Tag Manager Integration
Add ClickLens to your site through Google Tag Manager.
Option 1: Community Template Gallery (recommended)
The ClickLens template is in the GTM Community Template Gallery. There is nothing to paste: the template sets the config for you and needs only your site key.
- In your GTM container, go to Tags → New.
- Click Tag Configuration, then Discover more tag types in the Community Template Gallery.
- Search for ClickLens.
- Click Add to workspace.
- Enter your Site Key (found in the ClickLens dashboard under Settings → Site Settings).
- Set the trigger to All Pages.
- Save the tag and Submit your container changes.
Option 2: Manual template import
If the template is not yet visible in the Gallery, you can import it manually.
- Go to Templates → Tag Templates → New.
- Click the three-dot menu and select Import.
-
Upload the ClickLens template file (
template.tpl). You can download it from our GitHub repository. - Click Save.
- Create a new tag using the imported template. Enter your Site Key, set the trigger to All Pages, and submit.
Option 3: Custom HTML tag (fallback)
If you prefer not to use templates, you can add ClickLens as a Custom HTML tag.
- In GTM, go to Tags → New.
- Select Custom HTML as the tag type.
- Paste the following code:
<script>window.clicklens=window.clicklens||function(){(window.clicklens.q=window.clicklens.q||[]).push(arguments)};</script>
<script defer src="https://app.clicklens.io/t.js"
data-site="YOUR_SITE_KEY"
data-cl-token="YOUR_BEACON_TOKEN"
data-endpoint="https://app.clicklens.io/api/v1/beacon">
</script>
Paste both lines. The first is a queue that catches any
clicklens('conversion', …)
call made before the deferred tag has loaded; leave it out and a thank-you page that
converts on load records nothing.
Replace YOUR_SITE_KEY
and YOUR_BEACON_TOKEN
with your dashboard values. Set the trigger to All Pages,
save, and submit. If GTM strips the data attributes, set
window.__clicklens
before the tag loads instead — see the
global config
in the installation guide.
Template configuration
When using the ClickLens GTM template (Option 1 or 2), you'll see these settings:
| Setting | Description |
|---|---|
| Site Key | Your unique site identifier from the ClickLens dashboard. Required. |
| Endpoint URL |
Defaults to
https://app.clicklens.io.
Only change this if you are using a custom endpoint.
|
Testing with GTM Preview mode
- In GTM, click Preview in the top right.
- Enter your website URL and click Connect.
- Your site opens in a new tab with the GTM debug panel.
- In the debug panel, verify that the ClickLens tag fired on the Container Loaded event.
-
Open the browser's Network tab (DevTools → Network). Filter by
beaconand confirm you see a request to the ClickLens beacon endpoint returning204 No Content.
Conversion tracking via GTM
Reporting a conversion needs a second tag: the community template only installs the tracking tag and stops there. Create a Custom HTML tag that fires on your thank-you or confirmation page:
<script>window.clicklens=window.clicklens||function(){(window.clicklens.q=window.clicklens.q||[]).push(arguments)};</script>
<script>clicklens('conversion', { type: 'lead', value: 49, currency: 'USD' });</script>
The stub line has to be in this tag too, not only in the tag that installed ClickLens: GTM
tags can fire before the ClickLens tag has loaded, and the stub is what holds the call until
it does. Set your own type,
value, and
currency, then set the
trigger to fire on your conversion page URL (e.g.,
/thank-you) or a
form-submit event, and submit and publish.
See the conversion tracking guide for what the conversion beacon records and how a conversion gets judged.
FAQ
Does the tag respect consent?
The tag honors window.__clicklens_consent
=== false, Global Privacy Control, and Do Not Track — see
Consent and privacy
controls for what each signal does. The community template has no consent field of its
own, so set that flag from your consent manager, or from a Custom HTML tag triggered ahead
of the ClickLens tag in your container, before the ClickLens tag fires.
Can I use the template with GTM for server-side tagging?
The ClickLens template is designed for the GTM web container (client-side). The tag needs to run in the browser to collect behavioural signals like mouse movements and canvas fingerprints.
Why does the template need inject_script permissions?
The template loads the ClickLens tracking script (t.js)
from the ClickLens CDN. GTM's sandboxed JavaScript requires explicit permission to
inject external scripts. The template only loads from
app.clicklens.io
(or your custom endpoint).
Will it conflict with my other GTM tags?
No. ClickLens runs independently and does not modify or interfere with other tags.
It uses a namespaced global variable (__clicklens)
to avoid conflicts.