How to Add Recently Viewed Products in WooCommerce
Running a WooCommerce store means paying attention to how shoppers actually browse, and one of the strongest signals you have is what they’ve already looked at. Adding a “recently viewed products” section isn’t a cosmetic flourish; it’s a deliberate move that lifts engagement, lowers bounce rates, and gives buyers a quick path back to items they were considering.
This guide walks through how to add recently viewed products in WooCommerce from both angles: the strategic case for the feature, and the actual implementation. You’ll see why it works, where to place it for maximum impact, and how to ship it either with a plugin or a small code snippet.

What Are Recently Viewed Products?
Recently viewed products are items a user has looked at during their session on your store. This feature keeps a log of the products and typically displays them in a widget, sidebar, or on product and cart pages.
From a customer’s perspective, it acts like a digital breadcrumb trail. Shoppers often click through multiple products before deciding on one. By seeing what they’ve recently viewed, they can easily return to a product without having to search for it again. This convenience improves usability and fosters more confident purchase decisions.
WooCommerce ships a basic [woocommerce_recently_viewed_products] shortcode, but it’s limited in styling and placement, which is why most stores still need a tailored solution. Knowing how to add recently viewed products in WooCommerce properly is essential for any store owner who wants to maximize the customer experience.
Why Should You Add Recently Viewed Products in WooCommerce?
Knowing how to add recently viewed products in WooCommerce is a crucial skill for enhancing your store’s performance. But why exactly is this feature so important?
First, it enhances the overall user experience. Shoppers navigate through many pages, comparing sizes, prices, colors, and more. Recently viewed product sections help them easily track back and re-evaluate choices without frustration.
Second, it boosts conversions. When visitors see items they’ve previously considered, it triggers memory and emotional connection, both powerful factors in eCommerce decision-making. Adding recently viewed products keeps these items top of mind, subtly encouraging customers to finalize their purchases.
Moreover, this feature reduces cart abandonment and increases cross-selling opportunities. Imagine a user who viewed five items but added only one to their cart. By showing the remaining four again, you’re giving them another chance to reconsider and potentially buy more.
The Psychology Behind Recently Viewed Products
The concept of recently viewed items taps directly into cognitive psychology, specifically, the “recency effect.” This is the idea that people tend to remember the last few items in a sequence more vividly.
By using this principle in eCommerce, you can nudge users toward actions they were already considering. Whether it’s a pair of shoes, a smartphone, or a handmade candle, recently viewed products remind users of what they found interesting. This psychological push increases the likelihood of a return visit, deeper site engagement, and eventual conversion.
Even better, this strategy complements other marketing techniques like retargeting, upselling, and personalized recommendations. It forms part of a cohesive user journey that feels personalized and intuitive.
How to Add Recently Viewed Products in WooCommerce (Without Plugins)
Let’s roll up our sleeves and get technical. If you want to learn how to add recently viewed products in WooCommerce without relying on plugins, here’s a clean method using custom PHP code.
This process requires basic knowledge of WordPress theme editing. We recommend using a child theme or a site-specific plugin to avoid losing changes during theme updates.
Step 1: Create a Session to Store Product IDs
Add this code snippet to your theme’s functions.php file:
function store_recently_viewed_products() {
if (!is_singular('product')) return;
global $post;
if (empty($_SESSION['recently_viewed'])) {
$_SESSION['recently_viewed'] = array();
}
$viewed_products = $_SESSION['recently_viewed'];
if (($key = array_search($post->ID, $viewed_products)) !== false) {
unset($viewed_products[$key]);
}
array_unshift($viewed_products, $post->ID);
$viewed_products = array_slice($viewed_products, 0, 5);
$_SESSION['recently_viewed'] = $viewed_products;
}
add_action('template_redirect', 'store_recently_viewed_products');
Step 2: Display the Recently Viewed Products
To display them, paste the following where you’d like the section to appear, typically in sidebar.php or a custom widget area:
function display_recently_viewed_products() {
if (empty($_SESSION['recently_viewed'])) return;
$recent_products = array_filter(array_unique($_SESSION['recently_viewed']));
echo '<h3>Recently Viewed Products</h3><ul>';
foreach ($recent_products as $product_id) {
$product = wc_get_product($product_id);
echo '<li><a href="' . get_permalink($product_id) . '">' . $product->get_name() . '</a></li>';
}
echo '</ul>';
}
add_action('woocommerce_sidebar', 'display_recently_viewed_products');
And just like that, you’ve added a powerful feature without bloating your site with extra plugins.
How to Add Recently Viewed Products in WooCommerce Using Plugins
If coding isn’t your cup of tea, or if you want more flexibility and design options, using a plugin is a smart alternative. Several robust plugins make this process painless.
1. Recently Viewed Products for WooCommerce
Recently Viewed Products for WooCommerce displays the products recently viewed by members and guests on a separate page.
2. YITH WooCommerce Recently Viewed Products
YITH is a trusted name in the WooCommerce ecosystem. This plugin offers beautiful templates, responsive design, and even shortcode integration for total control over placement.
3. ProductX, Gutenberg Product Blocks
ProductX includes a block specifically for recently viewed items and integrates seamlessly with block-based themes.
To install any of these:
- Go to your WordPress dashboard.
- Navigate to Plugins > Add New.
- Search for the plugin by name.
- Install and activate.
- Configure the settings under WooCommerce or Appearance > Widgets.
Remember, while plugins simplify setup, always test compatibility and performance impact before going live.
Where to Display Recently Viewed Products for Maximum Impact
Now that you know how to add recently viewed products in WooCommerce, placement becomes your next strategic decision.
- Sidebar Widgets: Ideal for product and category pages.
- Below Product Descriptions: Helps users stay engaged post-scroll.
- Cart and Checkout Pages: Smartly nudges last-minute additions.
- Home Page Sections: Serves as a reminder for returning visitors.
The goal is to balance visibility with subtlety. You don’t want the section to feel intrusive, but you do want it to be noticed.
Best Practices for Using Recently Viewed Products
Adding the feature is one thing, using it effectively is another. Here are a few professional tips:
- Limit the Number of Items: Display 4–6 products max. Overloading this area can feel overwhelming.
- Style Consistently: Ensure the design matches your theme for a seamless feel.
- Track Interaction: Use analytics tools to see how users interact with these products.
- Combine with Retargeting: Sync user behavior with your email campaigns or Facebook ads.
Also, avoid duplicating content. If a product already appears in another recommendation section (e.g., “You may also like”), exclude it from the recently viewed list.
Case Study: Increased Conversions Through Recently Viewed Products
One fashion retailer added a “Recently Viewed” widget to their sidebar and reported a 17% increase in return visits and a 12% boost in conversions within two months. Shoppers described a smoother experience and were more likely to return later to complete their purchase.
Such results aren’t coincidental. By simply understanding how to add recently viewed products in WooCommerce, this store owner tapped into natural buying behaviors and created a more intelligent shopping experience.

Frequently Asked Questions
Does WooCommerce track recently viewed products by default?
WooCommerce includes a basic [woocommerce_recently_viewed_products] shortcode that uses a cookie to remember what each visitor has looked at. It works, but layout and styling are minimal, which is why most stores end up using a plugin or a small custom snippet for proper placement and design.
Will recently viewed products slow my site down?
Not meaningfully. Most implementations store product IDs in a cookie or session and only query the database for those handful of IDs when rendering the widget. If you’re seeing slowdowns, check that the widget isn’t running uncached database queries on every page load and that lazy-loaded product images are enabled.
How many products should the widget show?
Four to six is the sweet spot for most stores. Fewer than four feels empty, more than six leads to decision fatigue and pushes important page elements (related products, reviews) further down the screen. Test with your own analytics if you want a more confident number.
Final Thoughts: A Simple Addition, A Powerful Result
Adding recently viewed products in WooCommerce is not just a trend, it’s a foundational UX improvement that can have a lasting impact on conversions, customer satisfaction, and brand loyalty.
Whether implementing it manually or through a plugin, it’s a low-effort, high-impact strategy. Take advantage of how users shop, think, and decide. Make their journey easier, and they’ll reward you with loyalty and more purchases.
If you want to scale your WooCommerce store smartly, knowing how to add recently viewed products in WooCommerce is one tactic you can’t afford to overlook.
Interesting Reads:
How to Create a Buy One, Get One Free Offer in WooCommerce