We’re transitioning to a new UI, and are in the process of updating our Webflow University courses and videos.

Site-level code

Run custom code across your entire site.

Site-level code

Run custom code across your entire site.

Site-level code

Site-level custom code is used when custom behavior needs to run across your entire site. It runs on every page, for every visitor, and any change you make applies everywhere at once. This makes it a good fit for shared tools and global behavior, but not for page-specific features.

A code snippet shown inside the Footer field within Webflow Site settings.

Site-level custom code works best when:

  • The behavior needs to run on every page
  • The code supports global concerns rather than individual pages
  • Managing the code in one place improves consistency and maintenance

Common examples include:

  • Analytics and tracking tools
  • Cookie consent or compliance scripts
  • Shared libraries used by multiple features
  • Global CSS rules that apply site-wide

In most cases, this code is provided by third-party services or shared internally by developers or legal teams, rather than written directly in Webflow.

How to add site-level custom code

To add site-level custom code in Webflow:

  1. Get the code snippet from the tool or service, such as an analytics provider or consent platform.
  2. Open your site settings and navigate to the Custom Code section.
  3. Paste the code into either the <head> or </body> area, following the provider’s instructions.
  4. Publish the site and confirm the code appears on every page of your site.

Placement of site-level code: <head> vs <body>

Like page-level code, site-level custom code can be added in two places:

  • <head> — loads earlier and is typically required for analytics, verification, or scripts that must initialize before page content
  • </body> — loads later and is better for scripts that interact with page content or can wait until the page has rendered
Third-party tools usually specify where their code should go. When they do, it’s best to follow those instructions.

Common mistakes to avoid

Because site-level custom code runs everywhere, mistakes here tend to have a wider impact. 

Common issues include:

  • Adding large or unnecessary scripts globally, affecting performance
  • Introducing conflicts between scripts that try to control the same elements
  • Making debugging harder, since issues can appear across many pages at once

Before adding site-level code, it’s worth asking:

  • Does this really need to run on every page?
  • Could it be limited to a single page instead?
  • What happens if this script fails or loads slowly?

If the answer isn’t clear, page-level custom code is often a safer place to start.

Best practices for using site-level code

To keep global code manageable:

  • Use site-level custom code sparingly
  • Avoid adding temporary experiments or one-off scripts globally
  • Remove unused or outdated code regularly
  • Add comments explaining what the code does and why it exists
  • Consider performance and future collaborators

Small habits here can prevent big problems later.

Got the hang of it?

You’ve learned how custom code can run on a single page or across your entire site. Now, we’ll look at how custom code works with the Webflow CMS.

No items found.

1

Getting started

Getting started
Getting started
Coming soon

1

Background & preview
5:00
Background & preview
Coming soon

1

Where you can add custom code
5:00
Where you can add custom code
Coming soon

2

Adding custom code

Adding custom code
Adding custom code
Coming soon

2

The code embed element
5:59
The code embed element
Coming soon

2

At the layout level (Code Embed element)
4:00
At the layout level (Code Embed element)
Coming soon

2

Page & site level code
Page & site level code
Coming soon

2

Page-level code
5:00
Page-level code
Coming soon

2

Site-level code
5:00
Site-level code
Coming soon

2

Custom code and the Webflow CMS
5:00
Custom code and the Webflow CMS
Coming soon

3

Managing custom code

Managing custom code
Managing custom code
Coming soon

3

Previewing, testing, & troubleshooting
5:00
Previewing, testing, & troubleshooting
Coming soon

3

Best practices for maintainable code
5:00
Best practices for maintainable code
Coming soon

4

Wrap up

Wrap up
Wrap up
Coming soon

4

Try it: Add custom code
3:00
Try it: Add custom code
Coming soon

4

Wrap up

Try it: add page level code
3:00
Try it: add page level code
Coming soon

4

Wrap up

Try it: add site-level code
3:00
Try it: add site-level code
Coming soon

4

Additional resources
4:00
Additional resources
Coming soon

Course progress

0%

Assessment

Up next

Custom code and the Webflow CMS

Working with custom code in CMS-driven content
Complete & continue
Complete course