Visual Search Widgets
Implement image-based product search and similar product discovery on your Shopify storefront with our easy-to-use widgets.
Our visual search widgets provide an easy way to implement advanced AI-powered image search and similar product discovery on your Shopify storefront. The widgets are designed to be lightweight, customizable, and simple to integrate.
Widget Overview
Layers provides two main visual search widgets:
Image Search
Allows customers to search for products by uploading an image or selecting part of an image on your site.
Shop Similar
Shows customers products visually similar to the one they’re currently viewing.
Installation
Add the Layers Widgets to your site by including a single script tag in your theme’s theme.liquid
file, just before the closing </body>
tag.
Script Attributes
Your Layers API key, which can be found in your Layers dashboard.
Enable debug mode for console logging. Useful for troubleshooting during development.
Global Configuration
After the script is loaded, you can configure the widget manager with global options:
Configuration Options
Your Layers API key.
Enable debug mode for console logging.
Image Search Widget
The Image Search widget allows customers to search for products using an image they upload or select.
Basic Implementation
Configuration Options
Container element or selector where the toggle button will be placed.
ID of a template element for custom content in the upload step. This can include sample images and helpful tips.
Upload mode: drag-drop
(shows a drag-and-drop area) or button
(shows a button for uploading, better for mobile).
Icon to use: ScanSearch
, Search
, or Camera
.
Additional CSS class names for styling.
Custom Template
You can provide a custom template for the upload step that includes sample images and helpful tips:
Reference Images
You can create clickable images that open the image search:
Event Handling
Listen for area selection events to perform custom actions:
Shop Similar Widget
The Shop Similar widget allows customers to view products similar to a specific product.
Basic Implementation
Configuration Options
Container element or selector where the toggle button will be placed.
ID of the product to find similar items for.
Icon to use (currently only supports Sparkles
).
Additional CSS class names for styling.
Advanced Filtering with Filter Groups
You can specify advanced filtering using a script tag with type “layers/filter-groups” inside the toggle element:
Customization
Theme Customization
Customize the look and feel of the widgets using CSS custom properties. You can set these in your CSS or update them dynamically:
For a complete list of theme properties, check out our theme customization reference.
Translation Customization
Customize the text used in widgets:
Analytics Integration
The widgets emit analytics events that you can subscribe to for integration with your analytics platforms:
Event Types
Event Type | Description |
---|---|
similar-opened | Shop Similar modal was opened |
similar-closed | Shop Similar modal was closed |
similar-product-clicked | A product in the Shop Similar results was clicked |
image-search-opened | Image Search modal was opened |
image-search-closed | Image Search modal was closed |
image-search-search | Image Search was performed |
image-search-crop | Image was cropped in Image Search |
Theme Customization Reference
Property | Default | Description |
---|---|---|
--layers-widget-color-primary | #ff4500 | Primary color for buttons and accents |
--layers-widget-color-primary-hover | #ff6347 | Hover state for primary color elements |
--layers-widget-color-primary-light | rgba(255, 69, 0, 0.05) | Light version of primary color for backgrounds |
--layers-widget-color-primary-transparent | rgba(255, 69, 0, 0.2) | Transparent version of primary color |
Troubleshooting
Widget Not Appearing
If the widget doesn’t appear:
- Check that the script is loaded properly
- Verify your API key is valid
- Look for JavaScript errors in the console
- Ensure the container element exists
Enable Debug Mode
Enable debug mode to see detailed logs in the console:
For more detailed troubleshooting, please contact Layers support.