koko-analytics icon indicating copy to clipboard operation
koko-analytics copied to clipboard

Feature suggestion: Show homepage and category pages in the table that now only shows posts & pages

Open arnelap opened this issue 4 years ago • 3 comments

The table in the bottom-left corner of the analytics page currently only shows posts, pages and other public post types. Should we add the homepage and category (archive) pages to this table?

Requested by:

  • https://secure.helpscout.net/conversation/1129506308/22636?folderId=3775430

Please vote on this feature suggestion using :+1: or :-1: below.

arnelap avatar Apr 09 '20 00:04 arnelap

I'd like to be able to do this eventually but it is not easy to do right now, as the plugin references pages and posts by their post ID (for performance, storage and simplicity reasons). So if a page does not have a post ID (eg. archive pages or a non-fixed front page) then it is only counted towards the site total, but not stored to show-up in the table on the bottom-left of the dashboard.

dannyvankooten avatar Mar 02 '21 08:03 dannyvankooten

Maybe you can add a fake id in this case? Something like 99999999 which will never happen in real life (at least, very unrealistically). is_home() is true in this case and the wp option "page_on_front" is 0, so there would be ways to recognize and trigger it

matthias-schaefer avatar Apr 11 '22 16:04 matthias-schaefer

I'd like to be able to do this eventually but it is not easy to do right now, as the plugin references pages and posts by their post ID (for performance, storage and simplicity reasons). So if a page does not have a post ID (eg. archive pages or a non-fixed front page) then it is only counted towards the site total, but not stored to show-up in the table on the bottom-left of the dashboard.

You should consider to add those data because categories are important pages for many sites.

A possibile solution: Create another table to store term data: wp_koko_analytics_term_stats in this table id points to a term_id of wordpress term table. Modify your code to detect if you have to store data in your koko posts table or in the new koko terms table. Store terms data separately and merge them in a query when you're going to draw charts in wordpress dashboard.

It should not hurt performances too much, since you have to check for terms only if your page id is -1. In backoffice dashboard you have to make some UNION query to put together data.

Another possible solution (maybe easier) is to use just one table (your existing wp_koko_analytics_post_stats, but the name could become ambiguous) and add a type field that says "post" or "term", you should also modify your primary key (it should be date-id-type) this maybe is easier to fetch data.

giuliopons avatar Sep 20 '22 09:09 giuliopons