A modern, fast, and UX-optimized "Recently Viewed" products section built for Shopify themes (optimized for Dawn). This solution uses the Shopify Section Rendering API and LocalStorage to provide a seamless experience with Zero Layout Shift (CLS).
- 🚀 Performance: Fetches product data asynchronously using AJAX, ensuring zero impact on the initial page load speed.
- 🖼️ Zero Layout Shift: Implements dynamic Skeleton Loaders that match the chosen image aspect ratio, preventing page jumping.
- 🛠️ Fully Customizable: Merchants can choose between Square, Portrait, or Adapt aspect ratios directly from the Shopify Theme Editor.
- 📱 Responsive: Built to work perfectly with Shopify’s standard grid system (Dawn theme compatible).
- 💾 Efficient Tracking: Uses
localStorageto track user history locally without slowing down the server.
- Go to Online Store > Themes > Edit Code.
- Under the Sections folder, click Add a new section.
- Name it
api-product-card.liquid. - Paste the code from
sections/api-product-card.liquidand save.
- Under the Sections folder, click Add a new section.
- Name it
recently-viewed.liquid. - Paste the code from
sections/recently-viewed.liquidand save.
- Under the Assets folder, upload or create
recently-viewed.js. - Under the Assets folder, upload or create
recently-viewed.css.
Open sections/api-product-card.liquid and ensure the render tag matches your theme's product card snippet (default is card-product for Dawn).
- Open the Theme Customizer.
- Navigate to a Product Page.
- Click Add Section and select Recently Viewed.
- Adjust the settings (Heading, Aspect Ratio) in the sidebar.
├── assets/
│ ├── recently-viewed.css # Shimmer animations & skeleton styles
│ └── recently-viewed.js # AJAX logic & LocalStorage handling
└── sections/
├── recently-viewed.liquid # Main section UI & Skeleton structure
└── api-product-card.liquid # AJAX fragment endpoint