Anomalous Behavior of Google Analytics

Asked

Viewed 840 times

1

Use the Google Analytics on my website however it has an anomalous behavior:

  • When I open 2 to infinite pages of my site in a single browser is computed as a single active user.
  • When I open 2 up to infinite pages of my site in 2 browsers are computed as 2 active users.
  • When closing pages is not updated the number of active users on the site.
  • When I leave the tabs open but without any update or redirect the number of online users is updated to 0.

I am using a code from google Analytics asynchronous and optimized (I put in an external . js file (which contains other javascript functions, however there is no interfrencia between variables)):

var _gaq = [['_setAccount', 'UA-63633330-1'], ['_trackPageview']];
(function(d, t){
    var g = d.createElement(t),
        s = d.getElementsByTagName(t)[0];
    g.src = 'http://www.google-analytics.com/ga.js';
    s.parentNode.insertBefore(g, s);
}(document, 'script'));

What is the reason for this anomalous behavior or this is the appropriate behavior?

Site link that provided the optimized version of Google Analytics: https://mathiasbynens.be/notes/async-analytics-snippet

  • I can give more details if necessary. just ask in the comments =D

  • Ricardo I just didn’t understand which of the behaviors is anomalous.

  • @Guilhermenascimento In my view all three, or I misinterpreted and these are the normal bodies?

1 answer

2


We can say that yes, all seem to me "correct" with the logic of the functioning of most of the "online accountants", I hope this helps you:

Q: When I open 2 to infinite pages of my site in a single browser is computed as a single active user.

  • R: Yes are considered unique as it is necessary to do the metric and usually used to define the customer’s step-by-step, for example on a shopping site if the user opens multiple windows or tabs will need to check where he went until he reaches the Goal (in this example would complete the purchase)

Q: When I open 2 to infinite pages of my site in 2 browsers are computed as 2 active users.

  • R: Each browser has one User-Agent (identification of the technologies the user is using to browse) different and also do not use the same session/cookies, so it is not possible to determine that they are different users. They could even use the IP, but if two computers use the same network the IP will be the same and this would cause conflicts and unreal data (mixed).

Q: When closing pages is not updated the number of active users on the site.

  • R: The browser has a javascript event called window.onbeforeunload, but it only works well in front-end, if you use it to make an ajax request for example, the moment you close the browser it will call the ajax, but you will not have time to complete the delivery of the order on the server, sometimes you can, but it is not guaranteed. They could use it to assist, but instead they use an approximate one-minute time to check the user’s activities, if the user has closed the browser, after one minute it is removed from the "amount of users online" and this is the most guaranteed process of working today.

Q: When I leave the tabs open but without any update or redirect the number of online users is updated to 0.

  • R: It is the same situation as the previous one, if the user is inactive on the site even with open tabs, the counter should disregard after one minute (~approximate) the user, because what matters is the activity within the site, if the user is in another tab has no reason to account for it. The moment it performs an activity the counter updates.

Completion

Browsers may fail, there may be power outage, so the "one minute" (~approximate) system is the best to check if the user is active compared to the event window.onbeforeunload. Note that this "method" is not only on google, but other similar and even simpler systems use the same procedure (like those online visitor support chats)

  • 1

    I am learning SEO now so I was still not sure if these behaviors were correct or not so I decided to check, now I know they are correct, thank you.

  • Guilhermenascimento one point I forgot to stress is that the code of Google Analytics is in an external file. js and that it was optimized (but by comments this optimization did not cause harm) these factors can influence something?

  • @Ricardohenrique Optimizado you mean that you modified how it is called or you recreated the code? Usually its code is called with document.createElement that includes a .js at runtime. I believe there is no problem adding within a . js on your server, provided the call occurs at the point that would be equivalent to $.ready of jquery.

  • Guilhermenascimento found this optimization on this site: https://mathiasbynens.be/notes/async-analytics-snippet the code has been reduced by 50% (and apparently works) and I copied the code and pasted it into the file. js out of any function.

  • @Ricardohenrique yes this optimization seems to work even :) Thanks for Sharing.

  • Guilhermenascimento, you’re welcome, but what I’d really like to know is if you put this code right on. js external (outside any function) has some risk or against indication?

  • 1

    So @Ricardohenrique can yes put inside a . js, but the time of his call I believe it has to be in the same $.ready, that is when the document is ready (unlike the onlonad that all Resources have to be ready), because as far as I remember we always add the ga before the </body> and this would be equivalent to .ready jquery. I haven’t worked with GA for a while, but I’ll see as soon as I get back from my mini-vacation :) - on Monday

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.