All courses Custom code in Webflow

Page-level code

Go to the next lesson

Page-level code

Run custom code on a single page.

Page-level code

Run custom code on a single page.

Page-level code

Page-level custom code is used when you need custom behavior to run on one specific page and nowhere else. It runs whenever that page loads, for every visitor, but does not affect other pages on the site. It’s the right choice when code shouldn’t be tied to a specific layout position and also shouldn’t apply site-wide.

A code snippet shown inside the Before \</body> tag field within Webflow Page settings.

‍Page-level custom code works best when:

  • The behavior is limited to a single page
  • The code doesn’t need to appear inside the layout
  • Running it elsewhere would add confusion or unnecessary load
  • You want to keep the impact small and contained

Common examples include:

  • Adding a marketing or analytics script to a single landing page
  • Loading a chat widget only on a contact or support page
  • Running a small script that targets elements unique to one page
  • Adding an A/B testing or experiment script for a campaign page

In many cases, this code is copied from third-party tools and added as a snippet, rather than written from scratch.

How to add page-level custom code

To add page-level custom code in Webflow:

  1. Copy the code snippet from the tool or service, such as an analytics platform, chat provider, or testing tool.
  2. Open the page settings for the page where the code should run.
  3. Paste the code snippet into either the \<head> or \</body> section, depending on the tool’s instructions.
  4. Save and publish the page to staging or production to confirm the code runs as expected.

Some custom CSS added at the page or site level won’t render in Preview mode. In those cases, you’ll need to publish to staging or a live site to see the results.

Tip: Some teams place shared custom CSS inside Components to make it easier to reuse and preview.

Placement of page-level code: \<head> vs \<body>

Page-level custom code can be added in two places:

  • \<head> — loads earlier and is typically used for tracking, verification, or scripts that need to run as the page starts loading
  • \</body> — loads later and is better for scripts that rely on page content or existing elements
Third-party tools usually specify where their code should go. When they do, it’s best to follow those instructions.

Common mistakes to avoid

Page-level custom code is flexible, but a few patterns can cause issues:

  • Duplicating the same script across multiple pages, which makes updates harder
  • Forgetting page-level code exists, especially on older or less-visited pages
  • Using page-level code when the behavior should be site-wide, leading to inconsistent experiences

If you find yourself copying the same snippet onto many pages, that’s often a sign that site-level custom code is a better fit.

Feeling good?

Now that we’ve covered page-level code, let’s take a closer look at custom code at the site level.

1

Getting started

Getting started

Getting started

Coming soon

1

Background & preview 2:00

Background & preview

Coming soon

1

Where you can add custom code 4: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 6:01

The Code Embed element

Coming soon

2

At the layout level (Code Embed element) 3:00

At the layout level (Code Embed element)

Coming soon

2

Page & site level code 3:36

Page & site level code

Coming soon

2

Page-level code 3:00

Page-level code

Coming soon

2

Site-level code 4:00

Site-level code

Coming soon

2

Adding custom code

Custom code in the Webflow CMS 3:01

Custom code in the Webflow CMS

Coming soon

2

In the Webflow CMS 5:00

In 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 4:00

Best practices for maintainable code

Coming soon

4

Wrap up

Wrap up

Wrap up

Coming soon

4

Try it: use the Code Embed element 4:00

Try it: use the Code Embed element

Coming soon

4

Wrap up

Try it: add page-level code 4:00

Try it: add page-level code

Coming soon

4

Wrap up

Try it: add site-level code 4:00

Try it: add site-level code

Coming soon

4

Additional resources 2:00

Additional resources

Coming soon

Course progress

0%

Assessment

Test your knowledge

Up next

Site-level code

Run custom code across your entire site.

Continue to next lesson → Complete course ✓