How to Inject a Umami script via NPM

How to Inject a Umami script via NPM

Here is the exact, step-by-step Nginx Proxy Manager (NPM) configuration to successfully inject a custom script into any host.

Do not use the standard "Advanced" tab, as NPM's default routing will override your rules. You must use a Custom Location.

  1. Edit your Seerr proxy host and ensure the Advanced tab is completely empty.
  2. Go to the Custom locations tab and click Add location.
  3. Fill in the standard routing details:
    • Location: /
    • Forward Hostname / IP: [Your Seerr IP or Container Name]
    • Forward Port: 5055
  4. Click the gear icon (⚙️) in that same row to open the Custom Nginx Configuration box.
  5. Paste the following snippet (replace the <script> tag with your tracking code):
# Disable upstream compression so Nginx can read and modify the HTML
proxy_set_header Accept-Encoding "";

# Target only HTML files to save resources
sub_filter_types text/html;

# Inject the tracking script right before the closing head tag
sub_filter '</head>' '<script defer src="https://umami.domain.com/script.js" data-website-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"></script></head>';

# Run only once per page load
sub_filter_once on;
  1. Click Save.

Remember to force-refresh your browser (Ctrl + F5 or Cmd + Shift + R) to clear the cache and see the injected script in the source code.