A
A
Alexey2017-05-17 22:37:25
PHP
Alexey, 2017-05-17 22:37:25

Why are view rates different?

Hello! Visitors go to the site from facebook, where I publish links to news. When opening a page in php, I increase the counter of news views by one:

$db->query("UPDATE `news` SET `views` = `views` + 1 WHERE `id` = {$news_id} LIMIT 1");

And constantly the number of views in the database of each news is tens of times greater than what google analytics and yandex metrics show on the entire site. At the same time, the increase in viewing is only one unit (in another place it does not exactly increase anywhere). the difference is something like this (in the database 10k views, metrics and analytics - 500 visitors)
Maybe someone came across or have any suggestions?
I have an option that robots also visit the page, but the difference cannot be too big for so many robots in a couple of hours.
Can there be some kind of error on the side of the site, in which the page is processed by the script, but the user does not open it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem, 2017-05-17
@devspec

Look at the logs, what to guess?
There are a lot of robots now, so it may well be

so many robots in a couple of hours

P
profesor08, 2017-05-17
@profesor08

Each access to this page is 1 view. F5 spamming can get you lards of views. Your solution counts the number of page loads, a useless exercise, it makes no sense to build some kind of statistics on this data. To get started, track clicks on the link by adding some parameter to the address: site.ru/news/?ref=facebook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question