How to track pages in a single page application with Google Analytics?

A Single Page Application (SPA) loads the resources required to navigate throughout the site. This is for the first page load and SPA is a web application or website.

The content loads dynamically when your site’s link is clicked and the user interacts with the page. On load, the data stored in the tracker updates as well.

Update the tracker

ga('set', 'page', '/new-page.html');

Record pageview

Send a pageview immediately after the tracker updates −

ga('send', 'pageview');

Updated on: 25-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started