How to Play a Level-Up Sound at the End of an Article in Webflow
Learn how to play a level-up sound when a visitor finishes reading a Webflow article with the Web Audio API.
In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to play a level-up sound when a visitor finishes reading a Webflow article, using the Web Audio API.
Example
🎮
Level-up sound
Do Mi Sol Do — Web Audio API
Do 523HzMi 659HzSol 784HzDo 1047Hz
Click to test
Note
Frequency
Timing
Do
523 Hz
0ms
Mi
659 Hz
120ms
Sol
784 Hz
240ms
Do (high)
1047 Hz
360ms, held 300ms
Understanding the melody
The Do-Mi-Sol-Do melody is the chord progression most universally recognized as a "victory" sound in gaming culture. It uses the Web Audio API's square oscillator for a retro 8-bit feel. No audio file is needed: everything is generated synthetically.
1. Add a level-up badge (optional)
Create a Div with the ID levelup-badge, set it to Fixed position, center it, and keep it hidden by default with display none. Add a message like "⬆ Level Up ! Article complete" in your own style.
2. Add the script in Footer code
(function() { var fired = false;
function playLevelUp() { var AudioCtx = window.AudioContext || window.webkitAudioContext; if (!AudioCtx) return; var ctx = new AudioCtx();
The Web Audio API requires a prior user interaction to work (autoplay policy). Scrolling counts as an interaction: a user who scrolls to the end of the article will have interacted with the page, so the sound will play. Never trigger this sound when the page loads without prior interaction.
Conclusion
A level-up sound creates a memorable moment and reinforces the feeling of accomplishment. Use cases:
Long technical articles that reward finishing the read
Tutorials with gamification
Academies and training platforms
Good to know
Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.