ES EN
Home Guides Google Tag Manager

How to add a quiz with Google Tag Manager

If your website already has Google Tag Manager, you can connect the quiz through it without touching the site code. Here are the steps:
Create a GTM account
Create an account and add your website to Google Tag Manager.
Creating a Google Tag Manager account
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).
GTM container code to install on the website
Copy the quiz code in LeadForms
In your dashboard, open the quiz and go to the “Publish” tab → the “On website” subtab. Choose a format that doesn't depend on an exact position, for example “Auto-open” or “Button” with the “Fixed” option on (a floating button). Formats like “Block on the page”, which need a specific spot on the page, are awkward to insert through GTM.
That screen has two code blocks, and you need both: the script for the <head> section and the code for the element itself (button or pop-up) for the page body.
Quiz code in “Publish” → “On website”
Create a tag in GTM
In GTM, go to “Workspace” and click “Add a new tag”.
Adding a new tag in GTM
Paste the quiz code
In the tag configuration, choose the “Custom HTML” type and paste both snippets one after the other (the script for the <head> section first, then the button or pop-up code). The order is not critical: the initialization script waits for everything to load on its own.
“Custom HTML” tag with the quiz code
Set the trigger and publish
Choose a trigger, for example all pages, save the tag and push the changes live with the “Submit” and “Publish” buttons.
Publishing the GTM container
Done
The quiz will run on your website through GTM in the format you chose: button, auto-open and so on.

Still have questions? Write to us

Name *
* Required field
Email *
* Required field
Message
Write to us!
We reply within 30 seconds