Craft CMS plugin to find recently viewed elements of any type
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Limited history to max 99 elements, removed a var dump Jan 10, 2019
.gitignore Initial commit Jan 7, 2019 Bump v1.0.3 Jan 10, 2019 Initial commit Jan 7, 2019 Updated craft slack name Jan 9, 2019

Recently Viewed for Craft CMS 3

Track what your users view and resurface it as you please.

Easily create lists of recently viewed articles, commerce products or anything else that you've modeled as an Element in Craft, even custom Element types.



This plugin requires a commercial license which can be purchased through the Craft Plugin Store.
The license fee is $14 plus $5 per subsequent year for updates (optional).


This plugin requires Craft CMS 3.0.0 or later.


Install the plugin from the Craft Plugin Store in your site's control panel or manually using composer:

composer require mattgrayisok/craft-recently-viewed


Once the plugin is installed you'll have access to two additional functions on all of your fluent element queries:

  • recentlyViewed() - Filter by recently viewed elements only
  • orderByDateViewed() - Order recently viewed elements by view date/time, most recent first


{% set recentBlogPosts = craft.entries.section('blogPosts').recentlyViewed().orderByDateViewed().all() %}
{% set recentProducts = craft.products.recentlyViewed().orderByDateViewed().all() %}


By default any element which is linked to a specific URL will be auto tracked. I.E. if you visit /blog/article-slug and Craft has been configured to automatically inject the entry variable into the corresponding template the entry will be auto-tracked.

You can disable this auto tracking behaviour in the plugin settings.

You can also manually track views in your twig templates using:

{% do craft.recentlyViewed.track(element) %}


{% do craft.recentlyViewed.trackId(elementId) %}

You can pass any element type into the former function as long as it implements craft\base\ElementInterface.


If you would like to clear the recently viewed history for any reason you can call:

{% do craft.recentlyViewed.clear() %}


If you encounter any issues during the use of this plugin please let me know by:

  • Creating an issue on GitHub
  • Dropping me an email: matt at mattgrayisok dot com
  • Finding me in the Craft Slack: @mattgrayisok
  • DMing me on Twitter: @mattgrayisok

I'll respond to critical issues as quickly as I can.


Created by mattgrayisok.

Icon made by Smashicons from is licensed by CC 3.0 BY