How to track page views with JavaScript

Set up page tracking with JavaScript to support custom analytics tools like Segment, Fullstory, Amplitude, etc.

Framer accelerates page loading with JavaScript, which is a fairly common approach for modern authoring tools (Next.js does the same thing).

That means that if a user clicks a link, only the content gets replaced, skipping the normal DOM events like DOMContentLoaded that analytics tools typically use.

So you need a bit of helper JavaScript to send the page view event. Unfortunately there isn't a very nice API to do this nicely in the browser so it takes a bit of hacking (but it works perfect).

- You don't need this for Google Analytics (it's built in)
- You can learn more about the method here: