Create a most viewed component in Matrix


(Nick Papadatos) #1

Matrix Version: 5.5

Now that the hit counter is deprecated and removed from Matrix does anyone know how we can replicate something similar? If you have found a way I’d love to hear from you.

i.e; Trying to create a most viewed component

Cheers
NckyP


(Nick Papadatos) #2

I’m guessing not by the lack of response??


(Lewis) #3

Hi @NickyP.

Have you tried using cookies? If I’m understanding you right, you want to persist a counter of the number of times each asset has been visited?

I guess, depending on the size of your site, cookies might be an option - store an array or asset IDs vs count??

Just a thought :slight_smile:


(Nick Papadatos) #4

Thanks Lewis - hmm, maybe I can push/store those asset ID’s into a specific metadata field.
I’ll do some testing…


(Lewis) #5

Another way might be to use a session variable @NickyP , created using the Public User Session Created trigger event and the Set Session Var trigger action.


(Iain Simmons) #6

You could use your existing Analytics, like Google Analytics, and have a script per component sending a custom event.

I’d be hesitant to use triggers on every component on every uncached page load, and if the user sees a cached version of the page, it may not even count it.