Search code examples
javascriptgoogle-analyticspageviews

Detect when my webpage send pageview request with javascripts ga function before deploy my webpage


Over my webpage I use the google-provided ga function in order to send pageviews to my panel.

But how I will detect during development of the webpage's javascript when the javascript send pageview?

I am asking because it may sends more pageviews that requested especially on infinite scrolling pages and single-page applications.

I am not asking how to debug javascript but I am asking on how you can gen an indication when the page's javascript sends a pageview into the google analytics WITHOUT/BEFORE the need of deployment. In other words how I will detect over the tools that browser provides to me in order to detect when my webpage sends a pageview.


Solution

  • Go to the browser's developer tools (either by pressing the F12 key or via your browsers menu) and go to Network tab.

    Afterwards on the page network filter for https://www.google-analytics.com/collect each time you see that entry over the network a new pageview gets sent to the google's servers.

    An alternative approach is to put console.log before or after ga function.