When to use custom code
Common use cases include:- Adding analytics scripts (beyond GA4/GTM)
- Installing chat widgets (Intercom, Zendesk, Drift)
- Adding cookie consent banners
- Loading custom fonts
- Inserting meta tags for SEO
- Adding conversion tracking pixels
- Custom event listeners
Adding a custom code block
- Open the settings panel for your brand
- Navigate to the Code section
- Click Add custom code
- Fill in the details:
- Name: A descriptive name (e.g., “Facebook Pixel”)
- Placement: Where in the document to inject the code
- Code: Your HTML, CSS, or JavaScript
- Save the code block
Placement options
You can choose where your code appears in the page:| Placement | Location | Best for |
|---|---|---|
| Start of head | Top of <head> | Meta tags, preload hints |
| End of head | Bottom of <head> | Stylesheets, fonts |
| Start of body | Top of <body> | Scripts that need early execution |
| End of body | Bottom of <body> | Analytics, widgets, tracking pixels |
Managing code blocks
Enable/disable
Each code block has a toggle to enable or disable it. Disabled code blocks are not injected into published pages. This is useful for:- Temporarily removing a script without deleting it
- Testing pages with and without certain code
- Seasonal tracking codes
Editing
Click on a code block to edit its name, placement, or content. Changes apply to all pages after you republish.Deleting
Remove code blocks you no longer need. This action requires confirmation since it affects all published pages.How it works
Custom code blocks are stored at the brand level. When you publish any page:- Blox collects all enabled custom code blocks
- Code is injected at the specified placements
- The assembled page is deployed
Examples
Facebook Pixel
Custom font
Cookie consent banner
Best practices
- Test before publishing: Verify your code works correctly in preview
- Use descriptive names: Make it easy to identify what each code block does
- Keep code minimal: Only add what you need to avoid slowing down pages
- Consider loading order: Place critical code earlier if needed
- Document external dependencies: Note which third-party services your code connects to