Site settings

Add a cookie banner

A cookie banner asks visitors whether they allow analytics and marketing cookies, and keeps your scripts from running until they agree. It opens on the pages that use its layout until the visitor answers, and then stays closed for the time you set.

What the banner does, and what it does not

The banner holds back two things until the visitor agrees:

  • The scripts you add in Project settings > Custom code with Runs set to After analytics consent or After marketing consent. Add analytics and other scripts shows how.
  • YouTube and Vimeo videos that play by themselves, in a Video block or a section background. They wait for marketing consent.

It does not hold back scripts added in Ghost Admin under Settings > Code injection, embeds inside your posts, Ghost's own scripts such as Portal and its analytics, or the cookies Ghost sets to keep members signed in.

We cannot tell you whether your site is compliant with the GDPR or any other law. Fantasma gives you the banner and the script blocking; which scripts need consent, what your banner says, and what your privacy policy covers depend on your site and your country. Ask a lawyer or your data protection authority when you are not sure.

Add the banner

  1. Open your project in Fantasma.
  2. In the icon rail, click the second icon, Layouts.
  3. In the Layouts list, click Default.
  4. Click the + next to Overlays, lower in the left sidebar. The Add Overlay to Layout window opens.
  5. Select the Cookie banner category.
  6. Click the banner you want. It is added to the layout, the shared header, footer and overlays of the pages that use it. Most projects have one layout, Default, so the banner is on every page. If some templates use another layout, add a banner to that layout too. To see a template's layout, click the template under Templates; the right sidebar shows it under Layout.
The Add Overlay to Layout window with the Cookie banner category showing Compact bar, Corner card, Full-width bar and With choices
Banner Where it sits Buttons
Compact bar Bottom center, as wide as its content Decline and Accept
Corner card Bottom right, as a small card Decline and Accept
Full-width bar Along the bottom edge Decline and Accept
With choices Bottom left, as a small card Choose, Decline and Accept. Choose shows a switch for Analytics and one for Marketing, and a Save choice button.

Accept allows both kinds of cookies, and Decline refuses both. In With choices, both switches start off. The banner remembers any answer, a decline included. Visitors can still use the page while the banner is open.

The banner reads "We use cookies to understand how the site is used. Privacy policy". The Privacy policy link points to /privacy/, so create a page with that address in Ghost Admin, or change the link.

  1. Click the banner's row in the layout's Overlays list. The canvas shows the banner.
  2. Click the text in the banner and type your own.
  3. To change the link, select the words Privacy policy and change the address in the link toolbar.

The banner is a pattern. A change that goes beyond its text, such as moving a button, asks whether to Change only here or Edit pattern. How patterns work explains the choice.

Let visitors open the banner again

Visitors need a way to change their mind. Add a link to #cookies, with words such as "Cookie settings", to a paragraph or a menu in your footer section in Fantasma, as Edit text on the canvas shows, or as an item in Ghost Admin's navigation. Clicking it opens the banner again, on any page whose layout holds the banner.

Choose how long a choice lasts

The banner asks again after Remember choice: 3 months, 6 months (the default) or 12 months. To change it:

  1. Click the banner's row in the layout's Overlays list. Its settings open in the right sidebar.
  2. Click Detach, under the banner's name. While the banner follows the pattern, its settings stay hidden, so this is the only way to reach them. The banner becomes a plain dialog that no longer follows the pattern, and its settings appear. Press ⌘ Z, or Ctrl Z on Windows, to undo it.
  3. In Remember choice, select the time.

It also asks again when you add a script of a kind it did not ask about before, such as your first marketing script.

Test the banner

In Fantasma, the canvas shows the banner while you select it in the Overlays list. The banner works on your Ghost site. After you publish the theme, as Publish your theme to Ghost shows, open your site in a private browser window. The banner shows. Click Accept, and the scripts set to wait for consent run, which your analytics service's live view shows. To see the banner again, click your #cookies link, or open a new private window.

Dialog section describes every setting of the banner and how its buttons work.

Was this article helpful?