Custom Code Snippets

Activating the Custom Code Snippets extension.

The Custom Code Snippets extension lets you add custom code to your website without modifying Blocksy’s theme files. Snippets can be loaded globally across the entire website or only on individual posts and pages.

This is useful for adding third-party scripts, analytics integrations, tracking pixels, custom JavaScript, CSS and other code that needs to be inserted at a specific location in the page.

Blocksy Pro required
The Custom Code Snippets extension requires Blocksy Companion Pro to be installed and active.

Getting Started

To activate Custom Code Snippets:

  1. Navigate to WordPress Dashboard → Blocksy → Extensions.
  2. Locate the Custom Code Snippets extension.
  3. Enable the extension.

Once activated, you can add code globally from the Customiser or configure snippets for individual posts and pages.

Global Code Snippets

To add code across the entire website, open Customiser → Extensions → Custom Code Snippets.

Configuring global code snippets.

The extension provides three insertion areas, letting you place code at the location required by the service or integration you are configuring.

Header Scripts

Code added to Header Scripts is inserted into the document’s <head> section. This location is commonly required by analytics platforms, verification services, external libraries and other integrations that need to load early in the page.

After Body Open Scripts

Code added to After Body Open Scripts is inserted immediately after the opening <body> element. Some third-party services, including certain tag-management configurations, provide a separate snippet specifically for this location.

Footer Scripts

Use Footer Scripts for code that should load near the end of the page. This is often appropriate for scripts that do not need to execute before the primary page content has loaded.

Choose the correct location
Always follow the instructions provided by the service whose code you are adding. Moving a snippet between the Header, After Body Open and Footer locations can prevent an integration from working correctly.

Per Page/Post Code Snippets

Custom Code Snippets can also be added only to a specific post or page. This is useful when an integration should run only in a particular section of the website rather than globally.

For example, a conversion-tracking script could be loaded only on a confirmation or Thank You page instead of being included on every page of the website.

To add a page-specific or post-specific snippet:

  1. Edit the desired post or page in the WordPress editor.
  2. Open the Blocksy settings panel.
  3. Locate the Custom Code Snippets section.
  4. Add the code to the appropriate Header Scripts, After Body Open Scripts or Footer Scripts field.
  5. Update the post or page to save the changes.
Adding code snippets to an individual post or page.

Working with Custom Code

The extension can be used for a wide range of integrations, but the code itself remains your responsibility. Only add snippets from sources you trust and make sure the code is intended for the insertion location you have selected.

Incorrect or malformed code can interfere with the front end of the website or with other scripts that are already running. When troubleshooting an integration, temporarily disabling the relevant snippet can help determine whether it is contributing to the issue.

Third-party integrations
The Custom Code Snippets extension provides the locations where custom code can be inserted. Configuration, compatibility and troubleshooting of code supplied by third-party services remain dependent on those services and the code being used.

Video Resources

Not the solution you are looking for?

Please check other articles or open a support ticket.