Webflow sync, pageviews & more.
NEW

I'm trying to add a script to my Webflow website, but it's not working. I added it to the header, but nothing happens when I test it with my IP address. Any solution? I'm not very familiar with JavaScript, so I'm not sure what's wrong.

TL;DR
  • Place the script in the correct section (Header or Footer) in Webflow’s Custom Code and publish the site.
  • Check for syntax errors, test on your live domain (not Webflow.io), and use browser Console tools to debug and confirm the script runs.

You’re trying to add a custom script to your Webflow site’s header, but it’s not executing or having any effect when you visit the site. This is usually due to common placement, syntax, or publishing issues.

1. Confirm Script Placement in Webflow

  • Go to your Webflow Dashboard and click on your project.
  • Click Project Settings > Custom Code.
  • Confirm that the script is inside the "Head Code" section if it’s meant to run before page load (such as analytics or tracking).
  • If it's meant to run after the page loads or interact with the page content, place it in the "Footer Code" (before the closing </body> tag).
  • Click Save Changes, then Publish the site to your domain — scripts won’t work unless the site is published.

2. Ensure Script is Syntactically Correct

  • Double-check for missing quotes, parentheses, curly braces, or semicolons.
  • If it’s a tracking script (like Google Analytics), use the correct and current version provided by the service.
  • If your script includes IP filtering (e.g., run only for your IP), make sure the IP detection is actually working in the browser.

3. Use Console to Debug

  • Open your live site in Google Chrome, right-click and select “Inspect”, then go to the Console tab.
  • Look for errors or warnings related to your script. They usually give hints to what’s wrong (e.g., “Uncaught SyntaxError”, “Unexpected token”, etc.).
  • If your script references elements by ID or class, make sure those elements exist at the time the script runs.

4. Avoid Running on Webflow.io Domain

  • If IP-based logic is part of the code, make sure you test it on your custom domain, not the webflow.io staging domain — some IP detection services or cookies may behave differently.
  • Also, services that rely on domain-specific credentials (like Meta Pixel, Google Tag Manager) may reject requests from non-authorized domains.

5. Wait for Proper Caching

  • Webflow sometimes takes a few minutes to fully publish custom code due to caching.
  • Wait ~2–5 minutes after publishing and then clear your browser cache or open the site in an incognito window to test.

Summary

To fix your non-working script, make sure it’s placed in the right location (Header or Footer), the syntax is correct, you've published the site, and you’re testing on your live domain. Use browser developer tools to identify errors and confirm the script is being loaded and executed.

Rate this answer

Other Webflow Questions