Adam
Adam

Reputation: 2017

If I use Google Analytics "pageview" twice on a page, does it count the page once or twice?

If I use Google Analytics "pageview" twice on a page, does Google count the pageview once or twice?

Here is the code on one page.

First "pageview" call

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>

Secondary "pageview" call

<script>
ga('set', 'page', '/mysite/custom/page');
ga('send', 'pageview');
</script>

Thanks for your help!

Upvotes: 2

Views: 2366

Answers (1)

nyuen
nyuen

Reputation: 8907

Twice. Each ga('send', 'pageview') call sends a pageview hit. But the second time you send it, you are changing the page path, so in your pageview report, it will show a different page. You can use something like GA Debugger or just check in your Network tab, and you will see a hit sent each time.

Upvotes: 7

Related Questions