Track navigation with Analytics of single pages that have JavaScript navigation


I recently created a personal page and would like to track the most visited areas of the site.
The problem is that the page is composed of a single file (eg index.html) and the navigation is all done in JavaScript, that is, the page is loaded only once.
Is there any way in Google Analytics to track users' browsing according to menu navigation?


Google Analytics has an Event Tracking system that I believe applies to your need. The details are here:

You add a line at the point you want to measure by creating an event (eg a click on a top menu item).

If you use ga.js, it looks like this:

_gaq.push(['_trackEvent', 'clique-no-menu', 'menu-superior', 'resumo']);

If you use the new analytics.js it looks like this:

ga('send', 'event', 'button', 'click', 'menu-superior', 'resumo');

Then just go to the Event Tracking part of Google Analytics and set up your analysis.

Note: If you are open to other options, I recommend Mixpanel , which was made just for that. The idea is the same as the Google Analytics Event Tracker, but particularly, I find it much simpler and more intuitive.

Scroll to Top