All docs

Snippets and where they show

A snippet is one piece of code you save in AI Boost Custom Code, with its place and the pages it shows on. A product of its own, not included in AI Boost's plans. The Custom Code screen inside AI Boost is something else, and AI Boost's Custom Code page describes it.

Getting started with AI Boost Custom Code covers the installation and the licence. The parts of this page marked "with a licence" need a site you have activated.

Add a snippet

Open AI Boost Custom Code, then Snippets, and press Add snippet.

A snippet's screen on WordPress, with its title and switch, the five types, the five places, two lines of HTML, a note, and Shows on set to All pages
  • Title is the name in your list. Visitors never see it.
  • On switches the snippet on or off without losing it.
  • Type and Place say what the code is and where in the page it goes.
  • Note is for you. Only this screen shows it.
  • Shows on decides which pages get it.

Nothing is stored until you press Save. Cancel goes back to the list and changes nothing.

The five types

TypeWhat you enterWhat is published
HTMLAny HTML, scripts includedThe code as you type it
CSSCSS without <style> tagsThe CSS inside <style>
JavaScriptJavaScript without <script> tagsThe code inside <script>
CSS fileThe address of a fileA <link rel="stylesheet"> to it
JavaScript fileThe address of a fileA <script src> to it

A file's address starts with https://, http://, // or /. For a JavaScript file, Loads adds defer or async, or leaves the tag As written.

The code is not checked or tidied. An unclosed tag in an HTML snippet can break every page it shows on, so paste what a service gave you whole, and look at the site afterwards.

The five places

PlaceWhere in the page
HeadJust before </head>
Start of bodyJust after <body>
End of bodyJust before </body>
Before the content, with a licenceAbove the text of one article, page or post
After the content, with a licenceBelow that text

Choose End of body for a script that can wait. It then cannot hold up the words your visitor came to read.

Before the content and After the content take HTML and JavaScript only. They work on the own page of one article, page or post. A list, a blog or a category page gets nothing there.

  • Joomla only The content is one article on its own page.
  • WordPress only The content is one page or post on its own page.
  • WordPress only Start of body needs a theme that calls wp_body_open. When a page of your site has shown that the active theme does not, the snippet's screen says so.

Snippets go into the HTML pages of your site. The admin, a feed and a JSON answer get none.

The order

At one place, snippets are published from the top of the list down. Drag the grip at the left of a row to move it, or focus the grip and press the up and down arrow keys.

Where it shows

All pages is free. Everything else in this section needs a licence.

On WordPress, All pages also covers the page a missing address shows, the 404 page. On Joomla, that error page gets no snippet.

Choose Selected pages, then + Add page for a page you pick from a list, or + Add address for one you type.

The page picker on WordPress, with the tabs Pages, Categories and Posts, the home page first, one page picked and the page under it marked covered
  • Joomla only The list has three tabs, Menu pages, Categories and Articles. A category covers its own page and its articles.
  • WordPress only The list has three tabs, Pages, Categories and Posts. Tags stand under the categories. The Posts tab starts with every item of a type, such as All posts. A category covers its own page and its posts.
  • Home page, at the top of the first tab, is whichever page is home.
  • A menu page or a page covers the pages under it, and a category its subcategories. Switch off and pages under it or and subcategories to keep to the one you picked.
  • A page is remembered by its ID, so a page you rename keeps its snippets. When a picked page is deleted or unpublished, its row says "This page no longer exists."

Add address takes a path on your site. A * stands for anything, so /offers/* covers every address under /offers/ but not /offers itself. Capitals and a slash at the end make no difference. An address you type with a ? is compared with the query string too.

Except on takes the same rows. A page in this list never gets the snippet, even when Shows on covers it.

Shows on and Except on for one snippet on Joomla, with a menu page that covers the pages under it, a typed address, one article left out, the line Covers with its list of pages, and two languages to choose from

Under the rows, Covers counts the pages they reach, with the exceptions taken out. Show the list names the first ten.

Joomla only Languages keeps a snippet to the languages you pick. With none picked, it shows in every language.

The list of snippets

The list of snippets on WordPress on an activated site, with each snippet's title, type, place, pages and switch, and its Copy and Delete buttons

Search by title, or filter by place or type. The switch in a row turns that snippet on or off at once. Copy puts a copy under the original, switched off, with "(copy)" after its title. Delete asks first, and deleting cannot be undone.

On a site without a licence

Each choice a licence opens carries a padlock, and With a licence beside it leads to the product's page.

A snippet's screen on Joomla without a licence, where Before the content, After the content, Selected pages, Except on and Languages carry the link With a licence

A snippet that already uses one of these, because the licence on the site was switched off, is kept. Its row says "Not published. It needs a licence." It is published nowhere, not even on the pages it was set to. You can switch it, copy it and delete it. To save it, clear what needs a licence first, or the screen answers "Not saved. Picked pages, exceptions, languages and the content places need a licence." When the licence is active again, the snippet is published as you set it.

A worked example

A hotel wants its booking banner on the rooms pages and nowhere else, and not on the family suite, which is closed for the winter. On Joomla, with a licence, this is the code and these are the steps.

<p class="banner">Book direct and breakfast is free.</p>
  1. Press Add snippet and title it Booking banner.
  2. Keep HTML, choose Start of body, and paste the code above.
  3. Choose Selected pages, press + Add page, tick Rooms on the Menu pages tab, and press Done.
  4. Under Except on, press + Add page, open the Articles tab, tick Family suite, and press Done.
  5. Press Save.

The banner stands on the Rooms page, on the pages under it in the menu and on the rooms' articles opened through it. The family suite and the home page stay without it. On WordPress the steps are the same, with Pages and Posts in place of the menu and the articles.

Check it on your site

Open a page the snippet shows on in a private window, and one it does not. View the page source and search for a word from your code. If it is missing, look at the snippet's switch, then its Shows on rows, and then clear any cache in front of the site.