doublesecretagency / craft-viewcount

View Count plugin for Craft CMS
Other
6 stars 4 forks source link

View Count for specified time periods #11

Closed AndrewMac closed 3 years ago

AndrewMac commented 3 years ago

Hello there

We really want to show lists of most-viewed entries for the last 24 hours, the last week, the last month, and the last year.

I've looked through the View Count documentation, but that doesn't seem to be possible; is that right? It seems that View Count only offers a sort function that operates on a normal element query, so unless it also adds something like a "dateViewed" parameter to Craft's element query we can't actually do that, can we?

Or can we? Does View Count add an element query parameter? Or is there some other way of doing thais?

Hope I explained that well enough!

Cheers Andrew Macpherson

lindseydiloreto commented 3 years ago

Hi Andrew,

The answer to this is both yes and no...

No, the default out-of-the-box tracking doesn't provide that much information. The tracking is condensed into a single value, which represents the cumulative number of views.

Yes, you can enable the "Complete View Log" to get a detailed record of each individual view. On the plugin's Settings page, you can check the box to log views on a more granular level...

settings@2x

All of the resulting data will be stored in the viewcount_viewlog table. You can access it a bit more easily using ViewLog records...

doublesecretagency\viewcount\records\ViewLog

This enables a parallel track of viewing data. Your database will grow quickly, but all the information you could possibly need is right there.

Hope that helps! 🙂

lindseydiloreto commented 3 years ago

Whoops, I almost forgot the most important part... you will need to use PHP to access this data.

It's all covered in greater detail here...