0
votes

I have enabled a hit page counter in my website (www.ludhianaweddings.com) to count daily visits. Its an Update SQL query on each and every page that is updated by 1 each time any page is visited. I am also using Google analytics to overview my site. Now i am getting different results in both. For me Hit page counter always show more visits than Google analytics. For example from last three days my hit counter visits are 319, 411, 379. While Google analytics showing 199, 266, 234 in its reports.

I have put my update query on top of the page and Google analytics code after closing body tag. Is it can be a reason for that ??

Sorry to those who will say it off topic as i had no other better option to ask this from expert(s).

Please help me out...Thanks in advance

2

2 Answers

2
votes

I doubt that you will ever get your Hit counter to match 100% with Google analytics. There are a lot of things that can cause Google analytics to not log a hit. The first being the user not having JavaScript enabled the second being possibly ad blocker.

There are also referral spam bots which will insert random hits into your Google analytics account directly and bypass your website 100%. In that case your Google analytics will record higher numbers then your hit counter.

It also depends on what metrics you are looking at:

  • ga:sessions The total number of sessions.
  • ga:users The total number of users for the requested time period.
  • ga:pageviews The total number of pageviews for the property.

These are all different numbers and may have different results depending upon how you look at them.

1
votes

This seems at least vaguely code related, so, not off-topic.

Placing JavaScript code after the closing body tag is technically wrong, although in most cases it will still work.

If anything you would put it before the closing body tag. Even that would not give you the optimum result, as this would not count users that have aborted the loading process before the page was finished.

But at the end of the day Javascript-based tracking will always give you less visits then a serverside solution. Many bots do not execute JavaScript, people can opt-out from tracking and some adblockers block Analytics tags from working. Not really much you can do about it, except trying to figure out if the sample you are catching with javascript tracking is still big enough to allow conclusions based on it (for the moment I'd say yes, usually it is).