Google Tag Manager
Install the Userback widget on your website using a GTM Custom HTML tag — no direct code changes required.
Before you start
- Your Userback access token — click the Code icon in the top-right corner of your workspace
- GTM already installed on your website — see Google's setup guide if you need help
Option 1: Basic installation
Use this if you don't need to pass user data to Userback.
- In GTM, go to Tags → New → Tag Configuration → Custom HTML.
- Paste the following code:
<script>
window.Userback = window.Userback || {};
Userback.access_token = 'YOUR_ACCESS_TOKEN';
(function(d) {
var s = d.createElement('script');
s.async = true;
s.src = 'https://static.userback.io/widget/v1.js';
(d.head || d.body).appendChild(s);
})(document);
</script>- Click Triggering and select All Pages (or configure a specific trigger condition).
- Name and save your tag, then skip to Publish and test.
Option 2: Installation with user data
Use this if you want to identify users in Userback — passing name, email, and ID alongside feedback submissions. This requires setting up GTM variables to pass user data dynamically.
Step 1 — Set up GTM variables
Create two GTM variables — one for the access token and one for user data. These can be either JavaScript Variables (reading from window) or Data Layer Variables.
In GTM: Variables → New → Variable type and create:
Userback Access Token— reads fromwindow.userbackAccessTokenUserback User Data— reads fromwindow.userbackUserData
Step 2 — Set values on your website
Before GTM loads, set the values on window — typically server-side rendered into a script block in your page <head>:
<script>
window.userbackAccessToken = 'YOUR_ACCESS_TOKEN'; // set server-side
window.userbackUserData = {
id: '123456',
info: {
name: 'Jane Doe',
email: '[email protected]'
}
};
</script>Step 3 — Create the GTM tag
In GTM, create a new Custom HTML tag and reference the variables you created:
<script>
window.Userback = window.Userback || {};
Userback.access_token = {{Userback Access Token}};
Userback.user_data = {{Userback User Data}};
(function(d) {
var s = d.createElement('script');
s.async = true;
s.src = 'https://static.userback.io/widget/v1.js';
(d.head || d.body).appendChild(s);
})(document);
</script>- Click Triggering and select All Pages.
- Name and save your tag.
Publish and test
- Click Preview in GTM to open Tag Assistant and verify the tag fires on the correct pages before publishing.
- Once confirmed, click Submit to publish your changes.
- Load your website — the Userback widget button should appear. Submit a test piece of feedback and verify it appears in your Userback dashboard.
That's it.Userback is now deploying via GTM. See the JavaScript SDK for additional configuration options.
Need help? Visit the Help Center or use the chat bubble on this page to contact our support team.