Drupal installation
Drupal Testimonials with a Custom Block
Drupal splits the job neatly. The script belongs in your theme as an external library, declared once. The widget itself is just an empty div, which fits in a content block that site builders can place in any region from Block layout.
- An external library entry for the theme
- The div for a content block body
- Block layout placement and page visibility
Code generator
Code for your theme and your block
Enter the widget id. Parts 1 and 2 are edits to your custom theme, made once. Part 3 is the only thing that goes into the Drupal admin, and you can repeat it for every widget.
Part 1 · Declare the script as an external library
mytheme.libraries.yml
# themes/custom/mytheme/mytheme.libraries.yml
storyproof-embed:
js:
https://app.storyproof.io/embed.js: { type: external, attributes: { async: true } }Part 2 · Load that library on every page the theme serves
mytheme.info.yml
# themes/custom/mytheme/mytheme.info.yml (add to the existing file)
libraries:
- mytheme/storyproof-embedPart 3 · Body of the content block, in Source view
Content › Blocks › Add content block › Body
<div data-storyproof-widget="YOUR_WIDGET_ID"></div>Clear the cache so Drupal reads the theme files again, place the block in a region, then view a page as an anonymous visitor.
The code is put together in your browser. Nothing you enter is sent.
The problem, solved
Where Drupal and embed code collide, and the split that avoids it
- Problem 1
The text format keeps eating my code
Drupal text formats run filters over everything editors save, and the safer formats exist precisely to strip dangerous markup.
How StoryProof solves it
Only the empty div goes into the block. A div with one attribute is ordinary markup, and the script never passes through a text format at all.
- Problem 2
I will not give editors Full HTML
Drupal’s guide warns that script saved into content can be used against other visitors, and suggests keeping permissive formats for trusted users.
How StoryProof solves it
The script lives in the theme, so editors never handle it. Whoever has rights to the block body only ever pastes a div.
- Problem 3
Testimonials needed in a sidebar and a page
Adding a script per block would load it twice on any page that shows both.
How StoryProof solves it
Because the library loads once per page and fills every StoryProof div, you can place a compact widget in a sidebar block and a fuller one in the content region.
- Problem 4
Who decides which quotes appear?
A testimonials content type in Drupal means typing and checking every quote inside the CMS.
How StoryProof solves it
Testimonials are approved in StoryProof, and you choose per widget which ones show, so the Drupal block never changes when the quotes do.
- Problem 5
Visitors cannot submit one on the site
Building a submission form with video upload and moderation in Drupal is a project of its own.
How StoryProof solves it
Link a menu item or button to your StoryProof collection link, or print it as a QR code.
In StoryProof
Install it on a Drupal site
Step 1 of 5
Add the library to your theme
In your theme’s libraries.yml file, add the external script entry from Part 1, with async set as an attribute. Then list it under libraries in the theme’s info.yml file, as in Part 2.
Step 2 of 5
Clear the cache
Drupal caches theme definitions, so clear caches from the Performance page or with Drush before testing.
Step 3 of 5
Create a content block with the div
Go to Content, Blocks and click Add content block. Give it a Block description such as Homepage testimonials, switch the Body editor to Source, paste Part 3, and save.
Step 4 of 5
Place it in a region
Go to Structure, Block layout, check the theme tab, click Place block next to the region, pick your block, set its title display and any page visibility, and click Save block, then Save blocks.
Step 5 of 5
Check as a visitor
Log out or use a private window and load a page in that region. Open Source on the block again if the widget is missing, to confirm the data attribute was kept.
Before you start
Drupal specifics
Your format must keep the attribute
Whether the data attribute survives depends on how the chosen text format’s editor is configured on your site. If Source view no longer shows it after saving, use a format that allows it.
Placement is per theme
Drupal’s guide notes that block placement is defined per theme. If you switch or add a theme, place the block again and add the library to that theme too.
Code access is required
The library approach needs someone who can edit and deploy theme files. On a hosted Drupal with no theme access, ask your developer or host.
No Drupal module
StoryProof is not a contributed module. The widget is embed code, and it shows a "Powered by StoryProof" badge until Pro.
Drupal docs as of 2026-11-13
Paths follow the Drupal User Guide and theming docs on drupal.org as read on 2026-11-13. Nobody has followed these steps on a live site yet; older Drupal versions name the block library differently.
FAQ
Questions people ask
Short answers to what usually comes up next.
Can I put both lines in the block body instead?
Only if the block uses a text format that lets the script through. Drupal’s guide advises limiting permissive formats to trusted users, so the theme library is the safer home for the script.
Can I load the script only on some pages?
Yes. Instead of listing the library in info.yml, attach it with attach_library in the Twig template for the pages or block that need it.
Do I need a new block for every page?
No. One placed block shows in its region on every page unless you limit it with the page visibility settings. Create extra blocks only when a page needs a different widget.
Will this affect my Drupal page cache?
The div is static markup and is cached like any other block. The widget content is fetched in the visitor’s browser by the script.
Still have a question? Ask the StoryProof team or book a demo.
Bring real testimonials into Drupal
Collect and approve them in StoryProof, then place one content block wherever they belong.
Sources
- Creating a Custom Block, Drupal User Guide. Checked 2026-11-13.
- Placing a Block in a Region, Drupal User Guide. Checked 2026-11-13.
- Concept: Text Formats and Editors, Drupal User Guide. Checked 2026-11-13.
- Adding assets (CSS, JS) to a Drupal theme via *.libraries.yml, Drupal.org documentation. Checked 2026-11-13.
Last updated 2026-11-13.