• Resolved glorain

    (@glorain)


    Hello,

    I noticed that some records in the table wp_popularpostssummary are wrong.
    Some records “pageviews” are different that 1. I noticed that sometimes it too the value of the “Sample Rate”.

    I think that all must be = 1, right ?

    I don’t understand why.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @glorain,

    When Data Sampling is not enabled then yes every page view is stored individually in the database (1 visit = 1 record = 1 view). If Data Sampling is enabled then the behavior is as you described. See How does Data Sampling work? for more details.

    Thread Starter glorain

    (@glorain)

    Hi,

    Thanks. I understand…

    But there is one thing that is still not clear for me :

    I use the code to add the visit count in a custom field of the post. There is an accuracy parameter. It’s the opposite of the sampling ? For Big website we need to use 10 while for sampling bigger is better. I don’t understand how it works.

    —————
    Accuracy:
    // 10 = 1 in 10 visits will update view count. (Recommended for high traffic sites.)
    // 30 = 30% of visits. (Medium traffic websites)
    // 100 = Every visit. Creates many db write operations every request.
    —————

    Thanks

    Plugin Author Hector Cabrera

    (@hcabrera)

    You mean the code from the pinned post, “How To: Sort a custom query by views (All time, monthly, weekly, or daily)“? If so, that code basically mimics the behavior of Data Sampling, except the logic is slightly different: say for example that you set $accuracy to 45, then if the random number generated by the code turns out be lower than 45 (eg. 6) the code will fetch the views count of the post and generate/update its post meta fields accordingly (views_total, views_daily, views_weekly, and views_monthly). Otherwise nothing will happen.

    The point of doing all that is to reduce the number of database writes: the less database writes the better your site’s performance will be. Increase $accuracy and that code will write more frequently to your database, reducing performance.

    • This reply was modified 4 years, 10 months ago by Hector Cabrera. Reason: Expanded explanation about custom meta fields
    Plugin Author Hector Cabrera

    (@hcabrera)

    Oh, just in case you didn’t notice it: you’ll want to read the comment I left on that topic or else you might find some unexpected results with your code.

    Thread Starter glorain

    (@glorain)

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Some visits are count more than once’ is closed to new replies.