How to make accounting system hits?


Task: on the website there are numerous (several thousand items), you need to start to develop an accounting system views - i.e., what goods look more or less and so on. It will be used for various systems recommendations.

How best to take account of the views?

  • +1 every time you reneder page
  • +1 each time after a full page load via ajax request

How to protect yourself from bots, spiders and other trash that may be wasted to wind the counter?
June 14th 19 at 20:35
4 answers
June 14th 19 at 20:37
Make a counter request to url that is inserted in the page as an empty <script src="/mycounter"></code><br> Firstly, bots usually don't load scripts, the second is very simple. And third, most likely the browser the page has already loaded.<br> Don't forget to cast uncached header, otherwise, brayzer once your downloading empty counter, more of it will not load.</script>
June 14th 19 at 20:39
Good afternoon, we have implemented the so in the model of the goods there is a field:
show_count = models.IntegerField(default=0)
In the class viewing the product (we DetailView) overridden method get_object:
def get_object(self, queryset=None):
 self.object = super(DetailViewPageView, self).get_object()
 self.object.show_count += 1
 return self.object

you can also apply if you just use the function when calling facility +1 and save()
June 14th 19 at 20:41
1. on the client downloaded
2. if such is not present, add it the ip in the database and did a +1 view.
3. if in database there are, delighted to see you again on our website :)
June 14th 19 at 20:43
Why velocimed to invent? Yandex Metric and Google Analytics.
I want to tie on various parameters of the system Advisory function. Google Analytics and Yandex metrics are not as flexible as I Nina. - Shanie_Armstrong98 commented on June 14th 19 at 20:46
Indeed, had not noticed. Well, the easiest way to do middleware and to filter bots by user agent. Of course not all filters out, but at least the search engines. I was watching some report on the system of recommendations, the presenter said that they do not filter bots, statistics not affected. Well, in fact it is not done in any way. - Willow17 commented on June 14th 19 at 20:49

Find more questions by tags Django