Add

Lorem ipsum

Lorem ipsum

A
A
A
CRO / Conversion

1 views

5 min

How to Control a Banner’s Display and Dismissal Using the Browser’s Local Storage in Webflow

Introduction

ElementID / ClassRole
Bannerid='banner'Element to show/hide
Close buttonclass='close-btn'Triggers closing and storage
localStorage keybannerClosedStores the closed state

In this tutorial, Sandro, cofounder of the Gemeos Webflow agency, shows you how to control when a banner appears and closes using the browser's local storage in Webflow.

Controlling when a promotional banner appears and closes using the browser's local storage improves the user experience. This technique keeps the banner from showing up on every visit, reducing interruptions and distractions for the user.

Here's how to do it:

1. Add the "banner" ID to your banner

2. Add the "close-btn" class to the element that closes your banner

3. Hide your banner by default

Your banner should be set to Display: None by default

good to know

This avoids a weird behavior where the banner shows by default and then gets hidden once the page loads

4. Add this code to the <body> of your page

 

good to know

localStorage lasts forever. For temporary banners (for example, valid for 7 days), store an expiration date instead of a boolean: localStorage.setItem('bannerClosed', Date.now()), then check whether the date is less than 7 days old.

5. All that's left is to test it

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.

Lorem ipsum dolor sit amet consectetur. Aliquam orci sagittis dignissim sapien praesent donec.

Lorem ipsum

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.

Published on 10.04.2025

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...