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 Footer if it interacts with page content and ensure it’s correctly wrapped in <script> tags.
  • Publish your Webflow site after changes, test on the live site (not preview), and use browser developer tools and IP fetch checks to debug functionality.

You're trying to add a custom script to your Webflow site, but it's not functioning as expected. If you've added the script to the header section and it's doing nothing, a few common setup or permission issues could be at play.

1. Confirm Script Placement

  • Go to Project Settings > Custom Code > Head Code to check if your script is indeed placed in the Header section.
  • If your script involves DOM manipulation or relies on page content, it may be better suited for the Footer section (just before </body>).
  • Scripts in the Header are loaded before the page content is fully available, which can cause timing issues.

2. Use Proper Script Syntax

  • Ensure your script is wrapped correctly like: <script>/* your code here */</script>.
  • Any syntax errors will silently fail in most browsers. Consider testing the script in a basic HTML page first.

3. If It Depends on Your IP, Log It

  • If your script is checking your IP, confirm how it’s being validated.
  • IP-based checks require a backend or third-party API like ipinfo.io or ipapi.co.
  • Console log your client's IP first to verify it's working:
    For example, use this line inside <script>:
    fetch('https://api.ipify.org?format=json').then(res => res.json()).then(data => console.log(data.ip));

4. Check with Browser Developer Tools

  • Inspect the page in your browser (F12) and go to the Console tab.
  • Look for JavaScript errors related to your custom script.
  • If nothing shows up, your script may not even be running — double-check placement and if it appears in the final source code (right-click > View page source).

5. Verify Webflow Publish

  • After adding or updating any custom code, you must click Publish on your Webflow project.
  • Changes in the Project Settings (Custom Code section) won't appear on the published site until re-published.

6. Test on Published Site, Not Webflow Preview

  • Scripts added in Project Settings > Custom Code only appear on published sites, not in the Webflow Designer preview.
  • Visit your actual live domain (e.g., yoursite.webflow.io) to test the code.

Summary

To fix your script issue, make sure it’s in the right place (often better in the Footer), correctly formatted, published, and visible on the production site, not just in preview. Use browser tools and simple IP fetch scripts to debug and confirm it’s running.

Rate this answer

Other Webflow Questions