Most sites don’t need anything on this page. The Northbeam Pixel tracks page views automatically every time a page loads.You only need this if your site is a single-page application (SPA): a site that changes pages without a full reload.
Which setup you need
Not sure which you have? Ask your developer whether the site is a single-page app.
How it works
On a normal website, every page change is a full page load. The pixel records a page view each time. On a single-page app, the URL changes but the page doesn’t reload. The pixel doesn’t run again, so those page views go untracked. To fix this, calltrackPageView() each time the page changes:
trackPageView() won’t work until the pixel has loaded.
Option A: Google Tag Manager
Use this if you manage scripts through Google Tag Manager.Step 1: Confirm the pixel tag is in Google Tag Manager
The Northbeam Pixel must be its own tag, firing on All Pages. It has to load before thetrackPageView() tag runs.
Step 2: Create a Custom HTML tag
- Go to Tags → New.
- Set Tag Type to Custom HTML.
- Paste this script:
if check makes sure the call only runs once the pixel is ready.
Step 3: Set the trigger
Pick the trigger that matches how your site changes pages:
To set up a History Change trigger:
- Go to Triggers → New.
- Set Trigger Type to History Change.
- Give it a name, for example
History Change - Virtual Page View. - Attach it to your
trackPageView()tag.
On some SPAs, History Change fires more than once per page change. If you see duplicate page views, open Preview mode and count the History events for one page change. If there’s more than one, limit the trigger to one
gtm.historyChangeSource value (for example, pushState only), or use a custom data layer event instead.Step 4: Test and publish
In Preview mode, confirm that:- The Northbeam Pixel tag fires on all pages
- The
trackPageView()tag fires only when the page changes without a reload - No extra page views appear on full page loads
Option B: In your site’s code
CalltrackPageView() from your app’s router each time the page changes. Make sure that:
- It runs on every page change that doesn’t reload
- It does not run on full page loads
- The pixel has loaded before it runs
React Router example
CalltrackPageView() whenever the location changes, using useLocation:
window.Northbeam.trackPageView() from the router’s navigation hook.
Shopify Hydrogen
Hydrogen has its own routing and analytics, and the right setup depends on your Hydrogen version. Work with your developer to callwindow.Northbeam.trackPageView() from your router’s navigation hook. The same rules apply: only on page changes without a reload, and only after the pixel has loaded.
Troubleshooting
Related
- Northbeam Pixel: what the pixel does, how to install it, and how to test it
- Troubleshooting Pixel Tracking