When it helps
This option suits you if editing your website’s code is inconvenient or not allowed, but Google Tag Manager is already installed: for example, a contractor runs the website and your marketer has access to GTM. The LeadForms code goes in through GTM once, and from then on you change quizzes and how they show up in your dashboard, with no more edits to the container.
Create a GTM account
Create an account and add your website to Google Tag Manager.
Install the GTM code on your website
Copy the GTM container code snippets and install them on your website (in
<head> and right after the opening <body> tag).
Copy the LeadForms code
In your dashboard, open the quiz and go to the “Publish” tab → the “On website” subtab → the “Site code” block and copy the code. It’s one code for the whole website, and it loads all your quizzes and widgets.
Choose how to show the quiz right there: where it appears and how it opens, for example with the LeadForms button or auto-open. “Block in the page” and “Button on the page” are awkward to use through GTM: their short code has to go in an exact spot on the page.
Create a tag in GTM
In GTM, go to “Workspace” and click “Add a new tag”.
Paste the LeadForms code
In the tag configuration, choose the “Custom HTML” type and paste the code you copied:
<script async src="https://script.leadforms.org/v1.js" data-key="YOUR_KEY"></script>
Set the trigger and publish
Choose the “All Pages” trigger, save the tag and push the changes live with the “Submit” and “Publish” buttons.
Done
Click the “Publish” button at the bottom of the LeadForms “Publish” tab: without it, your “Publish” settings don’t reach your website. The quiz will run on your website through GTM the way you set it up in “Publish”.
The “Check page” button in your account may not find code installed through GTM, because it isn’t in the page HTML. That’s normal: open your website and make sure the quiz shows up.
The “Check page” button in your account may not find code installed through GTM, because it isn’t in the page HTML. That’s normal: open your website and make sure the quiz shows up.
FAQ
No. The LeadForms code is one for the whole website and loads all your quizzes and widgets. A new quiz or a different display option is set up on the “Publish” tab, and you don’t need to touch the GTM tag. Install the code in one place only: either through GTM or directly in your website’s code.
Yes. Once the LeadForms code is loaded, any button or link on your website pointing to
#leadforms-ID (ID is the quiz number) opens the quiz. A link like your-site.com/page#leadforms-ID opens the quiz as soon as the page loads, which is handy for newsletters and ads.Check in this order: the GTM container code is on your website; the changes in GTM are published, not just the tag saved; the tag uses the “All Pages” trigger; and in LeadForms you clicked “Publish” at the bottom of the “Publish” tab. Then reload the page on your website.