Hello.
I got a strange request from my client. He asked me to tamper with the post views in order to “keep the counted pageviews in the database, but augment the numbers the visitors see”.
Apparently his major competitors either tamper with their pageview numbers, or are heard of having created bots crawling their pages every few minutes – so that local shop owners see high numbers in pageviews and pay for advertising in their websites. And as long as everyone does it, ‘we gotta keep up with the competition’, he says. Although I personally wouldn’t go down this road, he is the boss..
So, how could I possibly perform this task?
Manually updating post views by hand won’t work – the website has a lot of traffic already and 20-30 new articles each day. I even need to have caching mechanisms to keep the site up, so I’m using the AJAX counter. I need to do this algorithmically.
I tried manipulating some files eg. the ../includes/wp-booster/td_module_single_base.php, to display a mathematically reapproached number of pageviews.
Specifically, I changed the line:
$buffy .= '<span class="td-nr-views-' . $this->post->ID . '">' . td_page_views::get_page_views($this->post->ID) .'</span>';
into the line:
$buffy .= '<span class="td-nr-views-' . $this->post->ID . '">' . floor((td_page_views::get_page_views($this->post->ID))*1.5) .'</span>';
But little did I know that this approach wouldn’t really work. Ajax counter restored the original hits plus one on each impression.
So I updated the td_ajax.php file, on that same folder. In the last function that gets the views count, I changed:
$buffy[$post_id] = td_page_views::get_page_views($post_id);
into
$buffy[$post_id] = floor(td_page_views::get_page_views($post_id)*1.5);
Do I need to spell d i s a s t e r ? 😛 With each impression of the page, the total views were multiplied by 1.5! Thankfully the experiment was contained.
So now I am out of options and I’d love to know if you have any ideas on the matter. I know that providing the final solution to this headache is probably out of scope in this forum (unless ofc there is an easy and obvious one that I can’t see), but mere suggestions that I could pursue on my own, would really really help.
Thanks for reading my long question!
-
This topic was modified 9 years by
Mpampirina.
Hi,
the most simple alternative is to manually add your post views as there is a filed in the back-end that lets you add the numbers in and that’s that. You could add a +100 instead of a *1.5…so the counter will start at 100 views and go from there, or simply manually add the 100 views when creating a post in the back-end like so: http://screencast.com/t/1gZe3VRm
Make sure ti run tests on a testing platform first…not on the live site though 🙂
Thank you!
Hi Bogdan.
This is not what I asked. In case you missed it:
Manually updating post views by hand won’t work – the website has a lot of traffic already and 20-30 new articles each day.
That’s about 800-900 new articles a month!
I know how to update views manually of course but that’s not the point… The point is to do it algorithmically, for all posts, past, present and future, without my further involvement and without anyone having to keep track and waste their time doing such a thing.
Also I don’t want to add a few hundred views on a few posts. Visitors should get a consistent and gradual image of pageviews any time of the day.
So, if you happen to have any idea how to cook pageviews on the front end -and only in the front end, we don’t want to harm the data in the database-, please share..
Hi,
Unfortunately the front-end views are the same as the back-end. If you do not want to have the views altered, then you will have to create a separate function for the front-end views. There is no simple way of altering one without the other. Sorry but there is no simple solution I can provide as this falls beyond what the theme support can offer you. We suggest wither hiring a freelancer to help out or finding a plugin that can provide a separate altered post views counter and hiding the one from the theme.
Thank you for your understanding.
You are welcome, thanks for taking the time to read my question.
— An update – I found some postview leakage.
During a parallel investigation of why the views are generally lower while they used to be really high before the redesign, and google analytics even showing more that the ajax view counter, I realized one unpredicted case that causes views to disappear.
So my client has a method of writing an article: He begins it, publishing it for the people to see that something is happening, then keeps updating it with all details as they happen. The strange thing, was that he got a comment that the post views one moment were 80, the other moment were a mere 30 on a certain article.
It got me thinking. And I found the culprit: That custom field in Editing mode, doesn’t get Ajax updates as they happen. So when the client updates the article, he unknowingly updates it to the number of views it had when he first clicked to edit it.
I’m reporting it just in case you are interested in doing something about it, And maybe it solves another fellow’s wondering as to why their pageviews get lost.
Hello,
Well the post views were not created with this in mind. Usually articles are posted as a whole and a few adjustments made here and there, but it does not take a long time usually between posting and updating. We never encountered this type of article creation before. It is surely a unique example. I will pass this info on to our development team and see if there is any solution to this for future releases.
Thank you!
Well, yeah, I thought it was strange, too. Apparently is more common than we think, in live news sites, especially for hot topics that can last a few hours – eg. reporting and commenting on election results as they come. 😉