Shopify Guides

How to Add Recently Viewed Products in Shopify: A Comprehensive Guide

September 25, 2025
How to Add Recently Viewed Products in Shopify: A Comprehensive Guide

Table of Contents

  1. Introduction
  2. Why Add a Recently Viewed Products Section?
  3. Technical Steps to Add Recently Viewed Products
  4. Best Practices for Implementing Recently Viewed Products
  5. Conclusion

Introduction

When it comes to e-commerce, keeping customers engaged and on the path to purchase is vital. A staggering statistic shows that nearly 70% of online shoppers abandon their carts before completing a purchase. In this landscape, it’s paramount for Shopify merchants to leverage features that enhance customer experience. One effective feature that can help in this endeavor is the "Recently Viewed Products" section. This not only reminds shoppers of items they have shown interest in but also makes navigation across your online store seamless and intuitive.

In this blog post, we’ll explore how to add a "Recently Viewed Products" section to your Shopify store. We will discuss its importance, provide detailed technical steps to implement it, and highlight best practices to maximize its effectiveness. By the end of this article, you will be equipped with the knowledge to make your store more personalized and engaging, ultimately driving more conversions.

At ShipAid, we understand the importance of a reliable post-purchase experience. Our focus is on empowering merchants by providing them with innovative solutions that enhance customer satisfaction and retention, seamlessly tying into the relevance of adding features like recently viewed products.

Why Add a Recently Viewed Products Section?

Let’s dive into what makes a "Recently Viewed Products" feature beneficial for your Shopify store.

1. Facilitating Purchase Decisions

Shoppers often pause before making a purchase. By providing a quick reminder of their previously viewed items, you make it easier for them to revisit products they were considering. This familiarity can be the nudge they need to finalize their purchase.

2. Enhanced User Experience

Personalization is key in the world of e-commerce. A "Recently Viewed Products" section adds an interactive touch, making users feel understood, leading to increased satisfaction and loyalty. Think of it this way: your ability to remind a shopper of a product they showed interest in can significantly enhance the overall experience, making them more likely to return to your store.

3. Increased Engagement and Time on Site

When users see items they have previously browsed, they are naturally inclined to spend more time on your site. This additional engagement can lead to greater exploration of your offerings, ultimately leading to higher conversion rates.

4. Higher Conversion Rates

By keeping desirable products at the forefront, you can motivate hesitant customers to complete their purchases. This subtle reminder can have a substantial impact on your store's conversion rates.

5. Opportunities for Cross-Selling

Displaying recently viewed products can also open up opportunities for upselling and cross-selling. For instance, if a customer is interested in a specific item, showcasing complementary products can entice them to fill their carts even more.

Having seen these benefits, let’s get into the technical details of how to implement this feature within your Shopify store.

Technical Steps to Add Recently Viewed Products

Adding a "Recently Viewed Products" section involves a few coding steps, but don’t worry; we will guide you through each one methodically.

Step 1: Create a Recently Viewed Products Snippet

First, we need to create a snippet that will hold the logic to display the recently viewed products.

  1. Access Your Shopify Admin: Log into your Shopify account and navigate to the admin panel.
  2. Go to Online Store > Themes: Choose the theme you wish to edit and click "Actions" > "Edit Code."
  3. Create a New Snippet: In the snippets directory, click on "Add a new snippet" and name it recently-viewed-products.

Step 2: Add JavaScript to Track Views

We now need to incorporate JavaScript that will track which products customers have viewed. This requires editing the main JavaScript file for your theme.

  1. Open Your Theme’s JavaScript File: Navigate to the Assets folder and find theme.js or similar.
  2. Insert the Following Code:
// Track recently viewed products
let viewedProducts = JSON.parse(localStorage.getItem('viewedProducts')) || [];

// Function to add a product ID to the viewed products
function addRecentlyViewed(productId) {
    if (!viewedProducts.includes(productId)) {
        viewedProducts.push(productId);
        localStorage.setItem('viewedProducts', JSON.stringify(viewedProducts));
    }
}

// Call this function on product page load
addRecentlyViewed('{{ product.id }}');

This code captures the IDs of products viewed during a shopping session and stores them in the browser’s local storage.

Step 3: Render the Snippet on Product Pages

Next, we need to display the recently viewed products on the product pages.

  1. Open the Product Template: In the Sections folder, look for product-template.liquid.
  2. Locate a Suitable Position: Identify where you’d like the recently viewed products to show up, often below the main product details.
  3. Insert the Following Code:
{% assign product_ids = localStorage.getItem('viewedProducts') | split: ',' | reverse %}
{% render 'recently-viewed-products', product_ids: product_ids %}

This code retrieves the product IDs from local storage and renders them in the snippet we created earlier.

Step 4: Style the Recently Viewed Products Section

Now that we have the functionality, it’s time to style it to align with your store’s aesthetic.

  1. Open Your Theme’s CSS File: Again, navigate to the Assets folder and find your CSS file, typically named theme.scss.liquid or similar.
  2. Add Custom Styles: Insert styles to give the recently viewed section an appealing look. Here’s a basic example to get started:
.recently-viewed-item {
    display: inline-block;
    margin: 10px;
    text-align: center;
}
.recently-viewed-item img {
    max-width: 100px;
    height: auto;
}

Step 5: Test Your Implementation

After completing the above steps, it’s crucial to test the functionality:

  1. Preview Your Store: Navigate to a product page and view a few items.
  2. Check the Recently Viewed Section: Ensure that the recently viewed products are displaying correctly according to your design.

Best Practices for Implementing Recently Viewed Products

While having this feature is indeed beneficial, here are some best practices to keep in mind:

1. Limit the Number of Products Displayed

To avoid clutter, it's wise to limit the number of items displayed in this section (e.g., the last four to six items). This keeps things tidy and focused without overwhelming your customer.

2. Exclude Certain Products

You might want to exclude out-of-stock items or products with low ratings from appearing in this section, which can help maintain a positive user experience.

3. Ensure Mobile Responsiveness

Make sure that your recently viewed products section is responsive, physically and visually appealing on mobile devices. Testing the layout on various screen sizes is essential.

4. Regularly Clear Old Data

Implement a mechanism to clear older data from local storage to keep the recently viewed products relevant. You wouldn’t want to remind users of items they were interested in several weeks ago!

5. Monitor Analytics

Use analytics to gauge how often customers interact with the recently viewed products section. This data can be invaluable for further optimizations.

Conclusion

Incorporating a "Recently Viewed Products" section into your Shopify store can significantly enhance how customers interact with your e-commerce site. By reminding them of items they have previously shown interest in, fostering personalization, and encouraging returns to your online store, we demonstrate our commitment to enhancing the overall consumer experience.

As Shopify merchants, we have the tools to create a more engaging shopping environment. Together, we can take advantage of this feature, improve user satisfaction, and ultimately enhance our conversion rates.

Ready to elevate your Shopify store with this feature? For additional support in making every package a revenue opportunity, check out ShipAid’s range of solutions. Let’s grow together and ensure every shipment is a success!

FAQ

How do I add the recently viewed products feature without coding?
If coding seems daunting, consider exploring Shopify apps designed specifically for this purpose. Many of these apps come with user-friendly interfaces and customizable options to add a recently viewed products feature without the hassle.

Can I customize the appearance of the recently viewed products section?
Absolutely! You can style the recently viewed products section further by modifying the CSS in your theme’s stylesheet, allowing you to align it more closely with your store’s branding.

Will adding this feature affect my store’s performance?
If implemented correctly, a recently viewed products feature shouldn't have a significant impact on your store’s performance. However, it’s best to ensure your code is optimized and not burdening the browsing experience.

How can I test if the recently viewed products feature is working?
View multiple products on your store, then check to see if the recently viewed products section updates properly, reflecting the products you’ve browsed.

How can I limit the number of products displayed in the recently viewed section?
Adjust the products displayed by altering the code within the snippet. For instance, you can use Liquid’s limit filter to only show the last four products.

Implementing features like the recently viewed products can drive engagement, reduce cart abandonment, and ultimately lead to increased sales. Let’s make our Shopify stores welcoming environments where customers feel valued and encouraged to return!


Participation is optional and ShipAid is not insurance. It does not provide indemnification for loss, damage, or liability. Instead, it allows brands to offer a free replacement if an item is not delivered or arrives in unsatisfactory condition. ShipAid does not sell or ship products, but provides tools for brands to manage replacements. All resolution decisions are made by the brand and may require proof of damage or non-delivery or other information

Similar Posts

Read, Protect & Prosper

Start for free ($0/mo), No strings attached

Protect Your Shipments & Boost Your Profits, It's That Simple.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
White checkmark icon
Free Expert Installation
White checkmark icon
Cancel anytime