Add a field type for storing the visits count for a entry.
To install Visits count field, follow these steps:
- Download & unzip the file and place the
visitscountfield
directory into yourcraft/plugins
directory - -OR- do a
git clone https://github.com/jordypixelcode/visitscountfield.git
directly into yourcraft/plugins
folder. You can then update it withgit pull
- -OR- install with Composer via
composer require jordypixelcode/visitscountfield
- Install plugin in the Craft Control Panel under Settings > Plugins
- The plugin folder should be named
visitscountfield
for Craft to see it. GitHub recently started appending-master
(the branch name) to the name of the folder for zip file downloads.
Visits count field works on Craft 2.4.x and Craft 2.5.x.
With this plugin you can add a visitors count field to a section. The visits count will be stored in the entry's content, so you can use it in the craft.entries tag.
Add a field with type 'Visits count' to the sections you want to track. The field is just a disabled number field which stores the view counter.
Add the following code on the entry details page to increment the number:
{% do craft.visitsCountField.increment(entry) %}
Without the tag above the number will not increment, so you can add your own if-else statements if you want. The number will increment only once for the stored session ID, so refreshing the page will not increment the number.
To show the visits count, you can render your own custom field by using the handle:
{{ entry.visitsCount }}
- Reset visits count for a single entry
- Reset all visits for a section
- Reset all visits
- Clear session IDs in visit count history
Feel free to request any or fork this repo.
- Initial release
- Bugfix: javascript error fixed
- Bugfix: crash live preview, see #1
- Improvement: Speed up counting, see #2
Brought to you by Jordy Versmissen