Skip to content
    Guide

    Customising the cookie bar

    Last updated

    A cookie bar asks visitors whether they agree to cookies and similar tracking before a site uses them. Site Tools has its own cookie bar, built by MaintainHQ with no outside service, which you customise from the Stats screen.

    It comes with Stats, but it does more than Stats needs: other scripts on the site, such as an advertising pixel or a chat widget, can wait until a visitor has agreed.

    Switching the bar on or off

    The cookie bar switches on with Stats the first time Stats is switched on on a site. After that it is switched on and off on its own.

    Open the site page in MaintainHQ, choose Monitoring, then Stats, and open the Cookie bar tab. Use "Show a cookie bar on the site". In WordPress, the bar is listed as "Cookie bar" under Settings, MaintainHQ Site Tools.

    Choosing who Stats counts

    The Count visitors setting on the same tab decides how Stats and the bar work together:

    • Everyone (cookieless, so no consent is needed): the default. Stats counts every visitor whatever they choose in the bar.
    • Only visitors who accept analytics: Stats sends nothing until the visitor accepts analytics, and stops again if they withdraw it.

    If you choose the second while the bar is off, or while it does not offer analytics, nobody can be counted. MaintainHQ warns you when this happens.

    How the bar looks

    The Preview updates as you type. Try the buttons in it; nothing is saved until you press Save.

    • Position: Bar at the bottom, Bar at the top, or Box in the corner.
    • Colours: Background, Text, Buttons and Button text, each with a colour picker.
    • Logo address (optional).

    Wording and categories

    Under Wording you can change the heading, the message and every button label: Accept button, Reject button, Choose button, Save choices button, Cookie settings link and Privacy policy link. The Privacy policy address uses the site’s WordPress privacy policy page when left empty. If the site has no privacy policy page set, add the address here to show the link.

    Under "Categories visitors can choose":

    • Necessary: always on, with a description you can edit.
    • Analytics: switch "Offer analytics" on or off, and edit its name and description.
    • Marketing: switch "Offer marketing" on or off, and edit its name and description.

    Visitors see Accept all, Reject and Choose with equal weight, so rejecting is as easy as accepting. Choose shows a tick box per category and a Save choices button.

    Behaviour and asking again

    • Show a small Cookie settings button after the visitor has chosen: lets visitors change their mind later.
    • Remember each visitor’s choice for (days): 180 by default, from 1 to 395.

    The choice is kept in one strictly necessary first-party cookie on the visitor’s device, called mhq_consent.

    Press Save to save normally. Press "Save and ask everyone again" if you have changed what the site does with cookies: every earlier choice stops counting and the bar shows to everyone again.

    Reopening the bar, and other scripts

    Visitors can reopen the bar from any of these, so you can put a "Cookie settings" link in your footer:

    • The [mhq_cookie_settings] shortcode.
    • Any link to #cookie-settings.
    • Any element with the data-mhq-consent-open attribute.
    • The optional small Cookie settings button.

    For developers, scripts can wait for consent. In the browser, use window.mhqConsent.on(category, fn), or a script tag with type="text/plain" and data-mhq-consent="marketing", which runs once marketing is accepted. In WordPress, wp_script_add_data with mhq_consent holds an enqueued script back, and mhq_consent_script() prints a held-back tag. The mhq_consent_show filter hides the bar on a particular page.

    Frequently asked questions

    Do I have to use the cookie bar with Stats?
    No. Stats is cookieless and counts everyone by default, so you can switch the bar off if nothing else on the site needs consent.
    Does the cookie bar use an outside service?
    No. It is MaintainHQ’s own code, part of Site Tools, and stores the visitor’s choice in one first-party cookie.
    How do I let visitors change their choice later?
    Switch on the small Cookie settings button, or add a link to #cookie-settings or the [mhq_cookie_settings] shortcode to your footer.
    I changed my cookie categories. How do I ask visitors again?
    Press "Save and ask everyone again". Earlier choices stop counting and the bar shows to everyone.

    Let MaintainHQ run the routine

    Updates with automatic rollback, backups, uptime, security checks and client reports, with Gus to fix what breaks.

    Start free trial

    From £29 a month for up to 2 sites. Every plan starts with a 14-day trial.