Skip navigation |

Snippets

Use snippets to add reusable blocks of content to multiple pages within your site. Use them to add blocks of script functionality, such as widgets or conversion tracking.

What are Snippets?

Snippets are reusable blocks of simple content that you can add to multiple pages in your site. The content is maintained in one place making it easy to manage blocks of common content throughout your site.

Snippets are designed to contain script blocks that you cannot ordinarily add to your pages when editing them. They make it possible for you to add Google Conversion Tracking to any page in your site. You can also use them to easily add scripts that allow you to add third-party integration to your site.

How to create a snippet

The example below shows you how to use Snippets to add a London Underground map to your site, but the process is the same for whatever content you want to add.

1. Get the script code that you need to embed.

The code that you need to embed can be obtained from the third party of your choice. In this case, we will copy the code from the TFL website, http://www.tfl.gov.uk/widgets/?CMP=widget-banner&banner=mapsbanner-/home.aspx:

<div style="width:360px"><script language="JavaScript" src="http://www.tfl.gov.uk/tfl/syndication/widgets/tubemap/tubemap-iframe-stretchy.js"></script></div>

2. Create a snippet

  1. In your site's control panel, click the Snippets link. This will take you to the Snippet Management page.
  2. Click 'Add a new snippet'
  3. Give your snippet a name and then paste the copied code into the Snippet box. Click the 'Create' button.
  4. Your snippet will now be displayed on your Snippets page.
  5. Note that you can edit the snippet by clicking the snippet's name.

    Creating a snippet

3. Copy the snippet

Before you can add the snippet to the page(s) of your choice, you must copy a special snippet code to your clipboard. To do this, click 'Get Snippet' beside the snippet you want to use. A message will appear informing you that the snippet has been copied.

4. Use your snippet

When editing any page, simply press ctrl-v, or right-click and select 'Paste' to paste the snippet into your page. It will look something like this:

A snippet in authoring view

5. View your snippet

Now, when you save, exit and approve your page, the content of the snippet is output on your page:

The finished snippet

Script-only snippets

If you have a snippet that only contains JavaScript, such as the Google Conversion Tracking script, there is a more efficient way to embed this into your General Content pages.

1. Ensure that the snippet starts and ends with <script ... </script>

2. Add the script to your General Content page by selecting the snippet's name in the Page Script Snippet placeholder:

Selecting a snippet

This will ensure that the snippet is output as the last item in the page, which is where it needs to be for Google Conversion Tracking to function correctly.