Home Guides Quiz as a block on the page

How to embed a quiz inside a page

To show the quiz right inside the page, without a button that opens a pop-up, choose “Block in the page” in the “Publish” tab.
When it helps
A block works best when the quiz is the main action on the page: a landing page for ads, a “Get a quote” section, a service page. Visitors see the first question right away, with no button or pop-up, and the quiz looks like part of your website.
Open “Publish” → “On website” → “Block in the page”
Open the quiz and go to the “Publish” tab → the “On website” subtab. In the “Where the quiz appears” step, choose “Block in the page”. Right there, set the “Block height” (leave it empty to match the screen height), “Full width”, which devices to show it on (“Show on”: desktop / phone) and how the block looks “On phones”: “Block” or “Button instead of block” (opens the quiz in a window).
“Block in the page” and its settings in the “Publish” → “On website” tab
Add the LeadForms code to your website
Open the “Site code” block and copy the code. Paste it once on every page of your website, right before the closing </body> tag. It’s one code for the whole website: if it’s already installed, skip this step.
<script async src="https://script.leadforms.org/v1.js" data-key="YOUR_KEY"></script>
The “Site code” block in the “Publish” → “On website” tab
Paste the block code where the quiz should go
At the spot on the page where the quiz should appear, paste the short block code. Replace ID with your quiz number, the same one as in the direct link https://quiz.leadforms.org/ID.
<div data-leadforms-block="ID"></div>
Publish the quiz
Click the “Publish” button at the bottom of the “Publish” tab: without it, your changes in “Publish” don’t reach your website. To make sure everything is in place, click “Check page” and enter the page address: your account will show whether the code and the block are found.
Done
The quiz becomes part of the page content, right where you pasted the block code. On phones, it looks the way you chose in the “On phones” setting.
If the quiz is already on your website with the old code, it keeps working, but the new display options and widgets only come with the new code. The “Migration guide” in your account shows what to replace.
FAQ
In an element that accepts HTML: in Tilda, the “Other / HTML code” block (T123); in WordPress, the “Custom HTML” block. In other website builders, look for an “HTML” or “Code” element. Step-by-step guides: Tilda and WordPress.
Blocks that appear after the page loads are picked up automatically. If a block still doesn’t render, call window.Leadforms.refresh(). More in the guides for React and Vue.
Yes. The block shows wherever its code is pasted: add <div data-leadforms-block="ID"></div> to every page you need. The LeadForms code must be on all those pages too, and the block settings in “Publish” are shared by all placements.

Still have questions? Write to us

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