How to add a countdown timer announcement bar to Shopify without an app
Most themes, Dawn included, already have an announcement bar. What they don't have is a countdown. Here's how to add one without an app, and how to stay on the right side of consumer law while you do it.
First: only count down to a real deadline
A lot of countdown apps offer "evergreen" timers that restart for every visitor, so the sale always "ends in 2 hours". In the UK, the Digital Markets, Competition and Consumers Act 2024 bans falsely saying an offer is only available for a very limited time, and EU consumer law has a similar rule. Fake urgency also costs you trust with repeat visitors. So:
- Set the timer to the time your offer really ends, and end it then.
- Every shopper should see the same deadline. Never restart the timer per visit, session or cookie.
- When it reaches zero, take the bar down or say the offer has ended. Don't quietly start it again.
This is general information, not legal advice.
The snippet
- Go to Online Store → Themes → Customize.
- In the Header area, or at the top of a template, click Add section (or Add block) and choose Custom Liquid.
- Paste the code below, change the end date and the message, then save.
<div class="countdown-bar">
Autumn sale ends in <span data-countdown data-end="2026-11-30T23:59:00Z"></span>
</div>
<script>
(function () {
var el = document.querySelector('[data-countdown]');
if (!el) return;
var end = Date.parse(el.dataset.end);
function tick() {
var s = Math.max(0, Math.floor((end - Date.now()) / 1000));
if (s === 0) { el.textContent = 'ended'; return; }
var d = Math.floor(s / 86400), h = Math.floor(s % 86400 / 3600), m = Math.floor(s % 3600 / 60);
el.textContent = (d ? d + 'd ' : '') + h + 'h ' + m + 'm ' + (s % 60) + 's';
setTimeout(tick, 1000);
}
tick();
})();
</script>
The date is in UTC. The Z at the end means UTC. During British Summer Time (late March to late October), UK time is UTC+1, so 23:59 in London is 22:59:00Z. The rest of the year the two are the same. Always use the 2026-11-30T23:59:00Z form with a T. Safari can't read dates written with a space.
Give the bar a background with a little CSS, for example <style>.countdown-bar{background:#121212;color:#fff;text-align:center;padding:10px}</style>.
What the snippet leaves out
- Settings in the theme editor (message, link, end date and colours), so you don't edit code for every sale.
- Hiding the bar automatically once the deadline passes, or showing "Offer ended".
- Cleaning up its timer when the theme editor re-renders the section, so timers don't pile up while you edit.
- Screen-reader handling. The timer is marked as a timer, but it doesn't announce every second.
Or use the ready-made section (£12, one-off)
Our announcement + countdown section adds all of that, set up in the theme editor. It counts down to the real end date you enter, the same for every shopper, and never resets per visitor. It's tested on Dawn and Horizon. Other Online Store 2.0 themes may need small style tweaks.
FAQ
Can I have the announcement without a timer?
Yes. In our section, leave the end date blank and it works as a plain announcement bar with an optional link.
What timezone does the countdown use?
You enter the end time in UTC. Each shopper's browser counts down to that same moment, wherever they are.