First 100 spots 50% lifetime discount. Start free.

ClickWhale

Site-wide custom code

This is where code goes when it has to be on every page: a stylesheet tweak, a chat widget, a tracking pixel, a verification tag. You write it once and ClickWhale puts it on every page of the website.

WhereManage → Custom code, on four pages: General, Functional, Analytics and Marketing
Takes effectHTML and JavaScript within a minute of saving, no publish needed; CSS after you publish (how)

The four pages load at different moments. They hold the same fields, but General loads for everyone, always. The other three wait until the visitor has agreed to that kind of cookie. Picking the right page is how a pasted snippet stops being a privacy problem. There is nothing else to switch on.

Which page do I put it on?

The code…PageExamples
Sets no cookies and calls no other companyGeneralYour own CSS, a small script that opens something on click, a verification meta tag
Makes the site nicer to use, but isn't essential, and involves a third partyFunctionalA chat widget, a booking or reviews embed, a font or player from another service
Measures what visitors doAnalyticsGoogle Analytics, Clarity, Hotjar, a heatmap or session recorder
Advertises or follows people aroundMarketingMeta Pixel, Google Ads, LinkedIn Insight, any remarketing pixel

When in doubt, ask what the snippet does to the visitor's browser. If it stores anything or contacts anyone, it does not go on General.

For the best-known services, don't paste anything at all. Google Analytics, Google tag, Tag Manager, Meta Pixel, Microsoft Clarity, Plausible and search-engine verification all have a field of their own where you paste just the ID, and ClickWhale handles the script and the category for you. See Measuring your visitors. Only use this screen for services that aren't on that list.

The fields

General has four fields. The other three pages have the same fields minus the CSS.

FieldWhere it ends upUse it for
Custom CSSAdded to the end of your website's stylesheetStyling that has to apply everywhere
Custom JavaScriptA <script> near the bottom of every pageYour own scripts
Custom HTML (end head)Just before </head>Verification meta tags, third-party loader snippets that insist on the head
Custom HTML (begin body)Immediately after <body> opensSnippets that ask to be "as high in the body as possible", Tag Manager's <noscript>, most chat widgets

Fill in what you need and click Save. Each page saves on its own, so switching pages before saving loses what you typed.

Custom CSS is only on the General page: a stylesheet rule loads nothing and stores nothing, so there is no category for it to wait on.

When it goes live

This screen is one of the few places in ClickWhale where saving is sometimes enough:

  • HTML and JavaScript take effect within a minute of saving. The live site reads them from your website's settings and holds them for up to a minute, so it picks them up without a publish.
  • CSS needs a publish. It's baked into your website's stylesheet, and that file is only rebuilt when you publish (or preview).

Custom CSS also doesn't show inside the builder. The editor canvas draws your page from your design settings, not from your stylesheet, so use Preview to see the effect. See Saving, previewing and publishing.

Making your CSS take effect

Your CSS is added after everything ClickWhale generates, which sounds like it should always win. It usually doesn't, because ClickWhale styles each element by its own unique id, and an id beats a class no matter which comes last.

So a rule like .my-class { color: red; } will be ignored on any element whose colour you also set in Display settings. Three ways out, best first:

  1. Change it in the builder instead. If the design can be expressed in Display settings or a display set, do it there. See Display sets.
  2. Be more specific. body .my-class { … }, or target a page: .page-12 .my-class { … }. Every page's <body> carries a page-<number> class.
  3. !important. It works, and it's a promise that nobody will be able to override it in the builder later either.

Use /* … */ comments, never //. When your CSS is published it's flattened onto a single line, so a // comment would comment out everything after it. (// isn't valid CSS anyway.)

Adding a "cookie settings" link

Put data-cw-open-consent on any link or button and clicking it reopens the cookie dialog:

<a href="#" data-cw-open-consent>Cookie settings</a>

Add one to your footer. ClickWhale already puts a small cookie button in the corner of the page, but a footer link is what most visitors look for, and being able to change your mind easily is part of what the cookie rules ask for.

To make a script of your own wait for consent, see Checking cookie consent from your own code.

Common issues

I saved and nothing changed on the live site.

If it was CSS, publish. CSS only reaches the site through the published stylesheet. If it was HTML or JavaScript, give it a minute, then reload with a hard refresh; your browser may still be showing the old page.

My CSS does nothing, but I can see it in the page source.

It's being outranked by the element's own styling. See Making your CSS take effect above.

My CSS works in Preview but not in the editor.

That's expected. The builder doesn't use your published stylesheet. Judge it in Preview.

The widget loads for me but not for a colleague.

You accepted that cookie category and they didn't.

I pasted a snippet on Analytics and it never runs.

Check that the cookie bar is switched on and that you accepted analytics on your own site. Click the cookie button in the corner to change your choice. See The cookie bar.

Half my snippet is missing.

Some services give you two pieces, one for the head and one for the body. Both fields are on the same page. Make sure each piece went into the right one.

I typed something into one page and it appeared on another.

The four pages are separate records, so that shouldn't happen. What does happen is switching pages before clicking Save, which loses the typing entirely.

Everything broke after I saved.

Empty the field, save, and check the site recovers, then put the snippet back a piece at a time. An unclosed tag in a head or body field affects every page on the website, which is the reason to be more careful here than in a Custom code element.

What will you create today?

ClickWhale is a website management system created by Ikabus