All docs

Add the script to your site

Last updated 29 October 2026 · 1 minute read

Add one script tag to the <head> of every page. Eventfox then records page views, including navigation inside single-page apps, with nothing more to set up.

The script tag

Copy it from Settings → Install in your project, or from the Install screen after setup:

<script defer src="https://eventfox.example.com/ef.js" data-key="pk_live_xxxxxxxxxxxxxxxx"></script>

The address comes from your APP_URL, so check it shows your public address before you copy it. The key is the project's public key. It can only add events, so it is safe in your page source.

Allowed domains

Eventfox only accepts events from the domains listed in Settings → General → Allowed domains. Add every address your site is served from. Matching is exact: www.example.com and example.com are different, so add both if your site uses both. To test from your own computer, switch on the localhost option.

If events don't arrive, Settings → Public key lists the hosts that were refused today.

Next.js and other frameworks

Load the script with your framework's script component. In Next.js:

import Script from "next/script";

<Script src="https://eventfox.example.com/ef.js" data-key="pk_live_xxxxxxxxxxxxxxxx" strategy="afterInteractive" />

Or install the package and start it once, as early as you can in the browser. See the JavaScript SDK.

If your project is in Standard mode and you need consent first, add data-consent="pending" to the script tag. Nothing is sent or stored until your cookie banner's accept button calls window.eventfox.optIn(). In Privacy mode the script stores nothing on the visitor's device, so there is nothing to consent to. See Standard and Privacy modes.

Ad blockers

Some ad blockers block scripts named ef.js or requests to analytics hosts. Serving Eventfox from a subdomain of your own site, such as stats.example.com, keeps most visits countable.