PHPackages                             bnomei/kirby3-pageviewcounter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. bnomei/kirby3-pageviewcounter

ActiveKirby-plugin[Database &amp; ORM](/categories/database)

bnomei/kirby3-pageviewcounter
=============================

Track Page view count and last visited timestamp

5.3.2(8mo ago)251.1k1MITPHPPHP &gt;=8.2CI passing

Since Aug 27Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/bnomei/kirby3-pageviewcounter)[ Packagist](https://packagist.org/packages/bnomei/kirby3-pageviewcounter)[ RSS](/packages/bnomei-kirby3-pageviewcounter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (36)Used By (0)

Kirby Pageview Counter
======================

[](#kirby-pageview-counter)

[![Kirby 5](https://camo.githubusercontent.com/b1a1b2ccd58e96259a9722c2489d91f40378c01b6c4c3e9fd27ed1d12c269d7c/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f4b697262792f353f636f6c6f723d454343373438)](https://getkirby.com)[![PHP 8.2](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)[![Release](https://camo.githubusercontent.com/2b380323a3ce14959ddbf77fe56f65ae80e3bc9f287957cc29c1a7c69aea6f34/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/2b380323a3ce14959ddbf77fe56f65ae80e3bc9f287957cc29c1a7c69aea6f34/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)[![Downloads](https://camo.githubusercontent.com/1462b526f4671c272eb0774569dff373c62ea3b194e99ba1933cd3593af88055/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/1462b526f4671c272eb0774569dff373c62ea3b194e99ba1933cd3593af88055/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)[![Coverage](https://camo.githubusercontent.com/93a39dd47d1596a50b97e2200bfce80d83a17840147210797b8cb7dc99b29047/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f636f7665726167652f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-pageviewcounter)[![Maintainability](https://camo.githubusercontent.com/7a974d0431e9a5740fec977738102b9603f95dd6249c3abccb2de5b418c996c3/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f626e6f6d65692f6b69726279332d7061676576696577636f756e7465723f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-pageviewcounter/issues)[![Discord](https://camo.githubusercontent.com/36eaef1b06f4996feb7587aa3281dcbd658e57535bc6b5e10110ed108e7a7a03/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f646973636f72642f626e6f6d65693f636f6c6f723d3732383964612669636f6e3d646973636f7264266c6162656c)](https://discordapp.com/users/bnomei)[![Buymecoffee](https://camo.githubusercontent.com/62e55d1129b82bf9c2fd4656451e81ab87a9787e7c9676ca58276532ed9666ee/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f69636f6e2f646f6e6174653f69636f6e3d6275796d6561636f6666656526636f6c6f723d464638313346266c6162656c)](https://www.buymeacoffee.com/bnomei)

Track Page view count and last visited timestamp

Installation
------------

[](#installation)

- unzip [master.zip](https://github.com/bnomei/kirby3-pageviewcounter/archive/master.zip) as folder `site/plugins/kirby3-pageviewcounter` or
- `git submodule add https://github.com/bnomei/kirby3-pageviewcounter.git site/plugins/kirby3-pageviewcounter` or
- `composer require bnomei/kirby3-pageviewcounter`

Usage
-----

[](#usage)

Echo the tracking a `1px x 1px`-image or adding css anywhere in your template. Both techniques will increment the counter but technically they track in a different way.

**A) via image, tracking scroll below first fold**

```

```

**B) via css, tracking mouse hover on body**

```

```

How it works
------------

[](#how-it-works)

The tracking image will be moved below the fold and trigger the counter [with native lazy loading](https://caniuse.com/#feat=loading-lazy-attr) on first user scroll. Why? To avoid most of the bots. It will also work for cached pages using the [pages cache](https://getkirby.com/docs/reference/system/options/cache) (even when cached [static](https://github.com/getkirby/staticache)).

SQLite database (default)
-------------------------

[](#sqlite-database-default)

To view the tracked count and timestamp this plugin provides two optional fields (`viewcount` and `lastvisited`).

**in your page blueprint**

```
fields:
  counter:
    label: Page view count
    type: viewcount
  lastvisited:
    label: Page last visited
    type: lastvisited
    # format: 'DD-MM-YYYY'
```

Tip

Kirby has *day.js* built in which you can use to [format your date](https://day.js.org/docs/en/display/format) output.

You do not have to add anything to you config files. But you could make some changes to the defaults, like the path to the sqlite file if you wanted to.

**site/config/config.php**

```
