2

Does google analytics counts the pageviews if the url of the page changes by javascript?

For example. First I open the page example.com/about(1 pageview) in the browser, than I click on the link contacts, but instead of redirect, by ajax I pull that page, insert into the body of the page and also edit the url - making it from example.com/about to example.com/contacts by this way

Modify the URL without reloading the page

So, the url changes without page refresh. Will google analytics count the second pageview, or it is still one pageview? And if it will not be counted, can I change some options that it will.

Thanks

Community
  • 1
  • 1
dav
  • 8,931
  • 15
  • 76
  • 140
  • I think it is still one pageview. You could add the analytics code in a function add call that function when your url changes. – putvande Nov 19 '13 at 14:29
  • Thanks @putvande, maybe will work, will give it a try. – dav Nov 19 '13 at 14:32

1 Answers1

3

Google Analytics cannot count page changes if you use AJAX to load the pages. You need to use the _trackPageView function to manually register pageviews every time you change the page via JavaScript. Here's the documentation.

_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_trackPageview', '/home/landingPage']);
Taylan Aydinli
  • 4,333
  • 15
  • 39
  • 33