Skip to main content
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, call trackPageView() each time the page changes:
It takes no arguments. It records the page’s current URL.
Only call trackPageView() when the page changes without a reload.The pixel already records a page view on every full page load. Calling trackPageView() on full page loads too will create duplicate page views.
Before you start, make sure the Northbeam Pixel is installed on every page. 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 the trackPageView() tag runs.

Step 2: Create a Custom HTML tag

  1. Go to Tags → New.
  2. Set Tag Type to Custom HTML.
  3. Paste this script:
The if check makes sure the call only runs once the pixel is ready.

Step 3: Set the trigger

Don’t use an “All Pages” trigger. That fires on full page loads too and creates duplicate page views.
Pick the trigger that matches how your site changes pages: To set up a History Change trigger:
  1. Go to Triggers → New.
  2. Set Trigger Type to History Change.
  3. Give it a name, for example History Change - Virtual Page View.
  4. 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
Then Submit and publish your container. Unpublished changes don’t track anything.

Option B: In your site’s code

Call trackPageView() 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

Call trackPageView() whenever the location changes, using useLocation:
Place this component inside your router. Other frameworks work the same way: call 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 call window.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