Black Friday countdown bar for Shopify without an app (that ends when your sale ends)

Disclosure: I build No-App Sections; this guide was written with AI assistance. The snippet below was written for this guide. It passes Shopify Theme Check inside Dawn 16 and automated tests with a fake clock, but it hasn't been run on a live store, so try it on a duplicate theme first.

Most Shopify themes, Dawn included, already have an announcement bar. What they don't have is a countdown. For Black Friday that usually means installing an app for a few lines of JavaScript.

This guide builds one in a single Custom Liquid block. It counts down to a real end date, hides itself when the offer is over, and avoids the pitfalls that catch most copy-paste timers: page caching, Safari's date parsing, timezones and the theme editor. (For a general, year-round countdown bar, see countdown announcement bar without an app.)

First: count down to a real deadline

Many countdown apps offer "evergreen" timers that start fresh for every visitor, so the sale always "ends in 2 hours". The code for that is usually something like this:

// Don't do this: the deadline is invented on every visit.
var end = Date.now() + 2 * 60 * 60 * 1000;

Fake timers that reset on every visit can break UK and EU consumer protection rules on misleading urgency. In the UK, the Digital Markets, Competition and Consumers Act 2024 lists as a banned practice falsely stating that a product, or particular terms, will only be available for a very limited time in order to push an immediate decision. The EU's Unfair Commercial Practices Directive has an equivalent item on its blacklist. Fake urgency also costs you trust: repeat visitors notice when "ends tonight" never ends.

So, for this build:

  • The timer counts down to the moment your offer really ends.
  • Every shopper sees the same deadline. Nothing is stored per visitor, session or cookie.
  • At zero, the bar comes down. Don't quietly extend the sale or restart the clock.

This is general information, not legal advice. If you're unsure about a campaign, check the regulator's guidance (the CMA in the UK) or ask a lawyer.

The snippet

  1. Go to Online Store → Themes → Customize.
  2. In the Header group, click Add section → Custom Liquid. Drag it above the announcement bar if you want it at the very top.
  3. Paste the code below, change the end date, the text and the link, and set the section's top and bottom padding to 0 (Dawn's Custom Liquid section has padding by default).
  4. Save, and check it on a duplicate theme first if you can.
{%- liquid
  # The real end of your offer, in UTC (Z). 23:59 on 30 Nov in London is 23:59Z (GMT).
  assign sale_end = '2026-11-30T23:59:00Z'
  assign end_ts = sale_end | date: '%s' | plus: 0
  assign now_ts = 'now' | date: '%s' | plus: 0
-%}
{%- if now_ts < end_ts -%}
  <div class="bf-bar" data-bf-bar data-end="{{ sale_end }}">
    <a class="bf-bar__text" href="{{ routes.all_products_collection_url }}">Black Friday sale ends in</a>
    <span class="bf-bar__timer" data-bf-timer role="timer" aria-live="off"></span>
  </div>
  <style>
    .bf-bar {
      display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
      padding: 10px 16px; background: #121212; color: #fff; font-size: 14px;
    }
    .bf-bar a { color: inherit; }
    .bf-bar__timer { font-weight: 700; font-variant-numeric: tabular-nums; }
  </style>
  <script>
    (function () {
      var bars = document.querySelectorAll('[data-bf-bar]:not([data-bf-ready])');
      Array.prototype.forEach.call(bars, function (bar) {
        bar.setAttribute('data-bf-ready', '');
        var timerEl = bar.querySelector('[data-bf-timer]');
        // Safari rejects "2026-11-30 23:59:00Z", so turn the space into a T.
        var end = Date.parse(bar.getAttribute('data-end').trim().replace(/^(\d{4}-\d{2}-\d{2})\s+/, '$1T'));
        var interval = null;

        function pad(n) { return n < 10 ? '0' + n : String(n); }

        function tick() {
          // Removed by the theme editor? Stop ticking on a detached node.
          if (!bar.isConnected) { clearInterval(interval); return; }
          var s = Math.floor((end - Date.now()) / 1000);
          if (isNaN(s) || s <= 0) {
            clearInterval(interval);
            bar.style.display = 'none'; // the offer is over: take the bar down
            return;
          }
          var d = Math.floor(s / 86400);
          var h = Math.floor((s % 86400) / 3600);
          var m = Math.floor((s % 3600) / 60);
          timerEl.textContent = (d ? d + 'd ' : '') + pad(h) + ':' + pad(m) + ':' + pad(s % 60);
        }

        tick();
        if (bar.style.display !== 'none') interval = setInterval(tick, 1000);
      });
    })();
  </script>
{%- endif -%}

The example ends at 23:59 on Cyber Monday, 30 November 2026, London time.

How it works

A real end date, checked in two places

The end date is written into the page once (data-end) and every visitor's browser counts down to that same moment.

The bar is checked twice:

  • In Liquid ('now' | date: '%s'), so once the deadline has passed and the page is rendered again, the bar isn't in the HTML at all.
  • In JavaScript, on every tick. Shopify can serve a cached copy of a page, and in a cached page Liquid's now is the time the page was generated, not the time the shopper is looking at it. The script compares against the shopper's current time, so a stale page still hides the bar the moment the deadline passes.

Timezones: write the date in UTC

Z at the end of 2026-11-30T23:59:00Z means UTC. UK clocks go back on 25 October 2026, so from then until the end of March, London time is the same as UTC and 23:59:00Z is 23:59 in London. During British Summer Time you'd subtract an hour (23:59 in London is 22:59:00Z).

You can also write an explicit offset. For a US store ending at midnight Eastern time: 2026-11-30T23:59:00-05:00.

Always use the T between the date and the time. Safari won't parse 2026-11-30 23:59:00Z with a space. The script converts that form anyway, in case someone edits the date later.

It stops itself

  • At zero, it clears its interval and hides the bar. It doesn't loop back round.
  • If the date is mistyped (Date.parse returns NaN), the bar hides rather than showing "NaNd NaN:NaN".
  • If the page is already past the deadline when it loads (a cached page), no interval starts at all.

It behaves in the theme editor

The theme editor re-renders a section each time you change it. Two small guards stop timers piling up:

  • data-bf-ready marks each bar once, so a re-run of the script doesn't start a second timer on the same bar.
  • bar.isConnected stops the interval of a bar the editor has removed from the page.

Accessibility

role="timer" tells assistive tech what the element is. aria-live="off" stops screen readers announcing the time every second. font-variant-numeric: tabular-nums stops the digits jiggling as they change.

Limits worth knowing

  • The shopper's clock. The countdown uses the device's clock. If it's wrong by ten minutes, the bar hides ten minutes early or late for that shopper. The Liquid check uses Shopify's server time, but only when the page is freshly rendered. Your checkout and discount settings are what actually end the sale, so schedule the discount itself to end at the same time (Shopify discounts have an end date).
  • Say the deadline in words too. "Ends Monday 30 Nov, 23:59 GMT" is clear even if JavaScript fails, and it's harder to mistake for a fake timer.
  • Urgency isn't the only rule. "Was £60, now £40" claims need a genuine previous price too. The same "don't mislead" principle applies.

Testing checklist

On a duplicate theme:

  1. Set the end date two minutes ahead. Watch it count down to 00:00:01, then disappear.
  2. Reload after the deadline: no bar.
  3. Open it in Safari (or on an iPhone) and check it ticks.
  4. In the theme editor, change the Custom Liquid text a few times, then leave the page open for a minute. The countdown should keep ticking once per second, not jump.
  5. Check the console: no errors.

Want a ready-made version?

If you'd rather set this up in the theme editor than in code, our Announcement + countdown section does this for £12, one-off, with no subscription. It's the same idea as the snippet with settings on top: you set the message, an optional link, the end date and colours in the theme editor. When the countdown ends you choose whether the bar hides or shows "Offer ended", and if you leave the date blank it works as a plain announcement bar. Like the snippet, it counts down to the real end date you enter, the same for every shopper. You can see it in the live demo.

Buy the countdown bar, £12 Try the live demo

The snippet above covers the basics, though. If all you need is an honest Black Friday countdown, you're done.