Where to Put Custom Code in Framer: Head vs. Body Explained

Framer Tutorials

Feb 25, 2026

The Complete Guide to Framer Custom Code Placement

If you are building a premium website in Framer, you will eventually need to add custom code. Whether you are injecting SEO Schema markup, integrating Google Analytics, or adding a customer support widget, Framer makes it incredibly easy.

But when you open the Add Script modal, you are hit with a few confusing dropdowns: Placement (<head> vs. <body>) and Run (Once vs. Every Visit).

Guessing the wrong combination can slow down your site, break your tracking, or prevent search engines from reading your data. Here is exactly how to configure these settings and why they matter.

1. The "Placement" Dropdown: Where should the code go?

A webpage loads from top to bottom. Where you place your code dictates when the browser executes it.

Start of <head>

Code placed here is the absolute first thing the browser reads, before any text, images, or colors are loaded.

  • When to use it: Only for critical, lightweight tracking scripts that need to catch a user the millisecond they land.

  • Examples: The base Google Analytics (GA4) tag, Meta Pixel base code, or urgent redirect scripts.

End of <head>

This loads right after your site's core settings, but just before the visual design starts rendering on the screen.

  • When to use it: This is the sweet spot for data that search engines need to read immediately, or styles that need to load before the page appears to prevent layout shifts.

  • Examples: Schema Markup (JSON-LD) for SEO, custom CSS, or custom font libraries.

Start of <body>

Code placed here loads exactly as the visual content begins to render. It is rarely used in modern web development.

  • When to use it: Almost never, unless a specific third-party integration explicitly demands it.

  • Examples: Google Tag Manager's fallback <noscript> tag (for users who have JavaScript disabled).

End of <body>

Code placed here executes after your entire website has visually loaded.

  • When to use it: This is the safest place for heavy, functional scripts. By putting them at the end, you ensure your beautiful Framer design loads instantly, and the heavy code loads quietly in the background.

  • Examples: Customer support chat widgets (like Intercom), heavy animation libraries, or complex third-party calculators.

2. The "Run" Dropdown: When should the code fire?

To understand this setting, you need to understand how Framer works under the hood. Framer builds Single Page Applications (SPAs).

In a traditional website, clicking a link forces the browser to download a brand new page. In Framer, clicking a link feels instantaneous because the browser doesn't reload; Framer just seamlessly swaps out the content. Because the page never actually "reloads," you have to tell your custom scripts how to behave when a user clicks around.

Run: "Once"

If you set a script to run "Once," it fires on the very first page the user lands on and then permanently goes to sleep for the rest of their session.

  • When to use it: Global tracking pixels. If you have a TikTok or Meta pixel tracking page views, you usually want this set to "Once" (if it's tied to Framer's built-in SPA router) so you don't accidentally double-count the same visitor when they navigate between pages.

Run: "Run on every page visit"

This forces the script to wake up and re-evaluate its data every single time the user clicks to a new URL within your site.

  • When to use it: You must use this for CMS-driven data. If you are using Framer CMS variables to generate dynamic Schema Markup or dynamic page titles, the script needs to run on every visit. Otherwise, if a user clicks from Product A to Product B, the script will get stuck displaying the data from Product A.

The Cheat Sheet Summary

  • Google Analytics / Meta Pixel: Start of <head> + Run Once.

  • Dynamic SEO Schema (CMS): End of <head> + Run on every page visit.

  • Chat Widgets / Heavy Scripts: End of <body> + Run Once (usually).

Getting these settings right ensures your Framer site remains lightning-fast while giving you all the tracking and SEO power of a custom-coded web app.

Hey, I'm Agustin Acu

I run Akila Studio, a solo creative studio that feels like 10x. I design and develop strategic websites in Framer, built for growth.

Clients choose me because I combine the agility of a solo creator with the capabilities of a full team, delivering high-impact results, fast.

Crafted with purpose by Agustín.
This brand system is a living foundation built to grow and evolve.

From Buenos Aires, available worldwide.

Currently:

11:42 PM

Crafted with purpose by Agustín.
This brand system is a living foundation built to grow and evolve.

From Buenos Aires, available worldwide.

Currently:

11:42 PM