Google Tag Manager
Use Google Tag Manager (GTM) to deploy and manage the attribu.tech pixel without modifying your website code directly.
Setup
- Log in to your Google Tag Manager account
- Select your container
- Click Tags > New
- Name your tag (e.g. "Attribu Analytics")
- Click Tag Configuration and select Custom HTML
- Paste the following code:
<script>
(function() {
var script = document.createElement('script');
script.defer = true;
script.setAttribute('data-website-id', 'YOUR_SITE_ID');
script.setAttribute('data-domain', 'yourdomain.com');
script.src = 'https://attribu.tech/js/script.js';
document.head.appendChild(script);
})();
</script>Replace
YOUR_SITE_ID and yourdomain.com with your actual values from the attribu.tech dashboard.- Click Triggering, select All Pages, and click Add
- Click Save
- Click Submit at the top right, then Publish
Adding script options
You can add any script option as an additional setAttribute call:
<script>
(function() {
var script = document.createElement('script');
script.defer = true;
script.setAttribute('data-website-id', 'YOUR_SITE_ID');
script.setAttribute('data-domain', 'yourdomain.com');
script.setAttribute('data-allowed-hostnames', 'app.yourdomain.com');
script.setAttribute('data-allow-localhost', 'true');
script.src = 'https://attribu.tech/js/script.js';
document.head.appendChild(script);
})();
</script>Tracking custom events via GTM
To send custom events from GTM triggers, create a separate Custom HTML tag:
<script>
window.attribu && window.attribu("button_clicked", {
button: "hero_cta"
});
</script>Attach this tag to whichever GTM trigger you want (e.g. a click trigger on a specific button).
Troubleshooting
- No data appearing? Use GTM's Preview mode to check that the tag is firing
- CSP errors? If your site has a Content Security Policy, add
attribu.techto yourscript-srcandconnect-srcdirectives - Delayed data? GTM tags fire after the GTM container loads. Make sure your tag fires on All Pages as early as possible.
For advanced configuration options like proxying, cross-domain setup, or calendar tracking, see the script options reference.