How to add Asklet to Google Tag Manager
No access to your templates? Place Asklet on chosen pages with a Custom HTML tag in Google Tag Manager.
Use this when Google Tag Manager is already on your site and you can't edit its templates. If you can edit them, paste the snippet there instead: it is simpler, and it loads even when Tag Manager doesn't.
Steps
- 01
Copy your snippet
In Asklet, open your website and click Copy website snippet at the top.
- 02
Pick where the survey goes
Find a CSS selector for the element the survey should follow, such as article or .post-content. Your browser's developer tools show it when you inspect the end of an article.
- 03
Create a Custom HTML tag
In your container, add a new tag of type Custom HTML and paste the code below. Replace the selector and the src with your own.
- 04
Fire it on the right pages
Add a DOM Ready trigger that fires on some pages only, with a condition such as Page Path starts with /blog/. Check it in Preview, then submit and publish the container.
- 05
Check it on your live site
Open an article on a domain you listed in Asklet and answer the survey. To keep your own test answers out of the results, add the page in Asklet first: new pages start in test mode.
<iframe src="https://asklet.io/embed/s/<your-site>" title="Article feedback" width="100%" height="480" loading="lazy" referrerpolicy="unsafe-url" style="border:0"></iframe>- Keep referrerpolicy="unsafe-url" on the iframe - Asklet uses it to know which page the reader is on, so the right survey appears. The code below sets it with setAttribute before the iframe goes into the page.
- If your site loads Tag Manager only after visitors accept cookies, or your consent tool holds tags back, readers who decline or ignore the banner won't see the survey. The tag's Consent Settings decide whether it waits for consent.
- Content blockers that block Google Tag Manager stop this tag too, so some readers won't see the survey. A snippet in the template doesn't have that problem.
- If your site sends a Content-Security-Policy header, allow https://asklet.io in frame-src, or the browser blocks the iframe.
The Custom HTML tag
Replace article with your selector and the src with the one from your snippet. The code removes the iframe it added before, so the survey never shows twice if the tag fires again.
<script>
(function () {
var target = document.querySelector('article');
if (!target) return;
var old = document.getElementById('asklet-feedback');
if (old) old.parentNode.removeChild(old);
var frame = document.createElement('iframe');
frame.id = 'asklet-feedback';
frame.src = 'https://asklet.io/embed/s/<your-site>';
frame.title = 'Article feedback';
frame.width = '100%';
frame.height = '480';
frame.setAttribute('loading', 'lazy');
frame.setAttribute('referrerpolicy', 'unsafe-url');
frame.style.border = '0';
target.parentNode.insertBefore(frame, target.nextSibling);
})();
</script> Single-page apps
On a site that changes pages without reloading, a tag can fire before the new page has rendered, so the survey lands in the wrong place or keeps the last page's survey. Add the iframe in your code instead and key it by path: see the React, Vue and Svelte guide.
Troubleshooting
The tag fires but no survey appears
The selector found nothing on that page. Try it in the browser console with document.querySelector and your selector. If it finds the element, check the console for a Content-Security-Policy error.
The survey shows twice
The page also has the snippet pasted into its template or content. The tag only removes the iframe it added itself, so remove the pasted one.
Common questions
Can Google Tag Manager read readers' answers?
No. The tag only places the iframe. Answers go from the iframe straight to Asklet, and the page around it can't read inside the iframe because it runs on another domain.
Does the widget set cookies?
No. It sets no cookies and no tracking identifiers. It keeps one local storage entry listing the pages answered in the last 3 hours, as short codes, so readers aren't asked twice. The Cookie Policy describes it.
Related guides
Other platforms
All integrationsGet your first answers today.
Set-up takes a few minutes, and the free plan covers one website or app.
Start freeFree plan, no card needed.