Skip to main content

Overview

You can inject snippets with Stormkit. This is extremely helpful to manage third-party scripts like:
  • Analytics tools (Google Analytics, Plausible, etc.)
  • Chat widgets (Intercom, Drift, etc.)
  • A/B testing tools
  • Marketing pixels
  • Custom JavaScript or CSS
These snippets are handled at an environment level, which makes it possible to inject different snippets based on the environment.
Snippets management interface
The effects are immediate - you won’t have to redeploy when enabling or disabling snippets.

Accessing Snippets

To manage snippets:
  1. Click on an environment
  2. Look for the Snippets menu item in the left sidebar
  3. This page will display all snippets defined for this environment
  4. You can turn them on and off easily with a switch

Adding a New Snippet

1

Navigate to Snippets

From your environment dashboard, click on Snippets in the left sidebar
2

Create snippet

Click on New snippet button. A modal will pop up.
3

Configure snippet

Fill in the snippet configuration (see settings below)
4

Save

Click save. The snippet will be applied immediately if enabled.
Snippet editor modal

Snippet Settings

Location Options

Head (Prepend)

Injects the snippet at the beginning of the <head> tag. Best for critical CSS or meta tags.

Head (Append)

Injects the snippet at the end of the <head> tag. Commonly used for analytics scripts.

Body (Prepend)

Injects the snippet at the beginning of the <body> tag. Good for above-the-fold content.

Body (Append)

Injects the snippet at the end of the <body> tag. Best for non-critical scripts that shouldn’t block page rendering.

Common Use Cases

Google Analytics

Location: Head (Append) Path: .* (all pages)

Custom CSS

Location: Head (Append) Hosts: Specific domains only

Chat Widget

Location: Body (Append) Path: ^/(?!admin).* (all pages except /admin)

Environment-Specific Banner

Location: Body (Prepend) Enabled: Only on staging environment

Host Filtering

If you have multiple domains configured for your environment, you can specify which domains should display the snippet:
  • Leave empty to apply to all domains
  • Add specific domains (e.g., example.com, www.example.com)
  • Add multiple domains separated by commas

Path Filtering with Regex

Use regular expressions to control which pages display the snippet:
Test your regular expressions using regex101 before applying them.

Managing Snippets

Enable/Disable

Toggle the switch next to any snippet to enable or disable it immediately without redeploying.

Edit

Click on a snippet to edit its configuration. Changes take effect immediately.

Delete

Remove snippets you no longer need to keep your environment clean.

Best Practices

  • Use descriptive titles - Make it easy to identify snippets at a glance
  • Test on staging first - Verify snippets work correctly before applying to production
  • Keep snippets focused - One snippet per purpose (analytics, chat, etc.)
  • Use path filtering - Only inject snippets where needed to improve performance
  • Monitor performance - Heavy snippets can slow down your site
  • Environment-specific snippets - Use different snippets for staging/production (e.g., test analytics IDs)

Troubleshooting

  • Check that the snippet is enabled (toggle switch)
  • Verify the path regex matches your current URL
  • Ensure the host filter includes your domain
  • Check browser console for JavaScript errors
  • Clear browser cache and reload
  • Review the path regex pattern
  • Test your regex at regex101
  • Check if multiple snippets are conflicting
  • Move non-critical snippets to Body (Append)
  • Use async/defer attributes for script tags
  • Consider using path filtering to limit scope
  • Review if all snippets are necessary