Skip to main content

Installation

Add one script tag to your Nuvemshop Admin → Design → Scripts:
That’s it. The snippet automatically initializes on DOMContentLoaded.

Configuration

How It Works

The snippet:
  1. Finds the Nuvemshop search form via these selectors (in order):
    • #search-form
    • form[action="/search"]
    • form[action*="search"]
    • .search-form
    • Falls back to input[name="q"] and traverses to the parent <form>
  2. Intercepts form submit — calls POST /api/v1/search instead of native search
  3. Attaches an autocomplete dropdown to the search input (200ms debounce)
  4. Renders a product grid in #alana-search-results at the top of <main>
  5. Updates the URL to /search?q=... without page reload (history.pushState)
  6. Restores search state on direct navigation to /search?q=...

Autocomplete

The dropdown appears after 2+ characters and shows up to 5 suggestions from /api/v1/autocomplete. Each suggestion shows the search term and result count. Clicking a suggestion performs an immediate search.

Event Tracking

The snippet tracks: Events are sent to /api/v1/events with a persistent visitor ID stored in localStorage under _alana_vid.

Programmatic API

The snippet exposes a frozen global for programmatic use:
window.AlanaSearch is frozen with Object.freeze to prevent prototype pollution from third-party scripts on the page.

Troubleshooting

[Alana Search] No search form found
  • Your theme doesn’t use a standard search form selector
  • Add name="q" to your search input, or contact Alana Support with your theme name
Autocomplete not appearing
  • Confirm the script tag is loading (check Network tab in browser DevTools)
  • Check the browser console for [Alana Search] Initialized successfully.
Products show “No image”
  • Ensure products in your catalog have image_url set
  • Trigger a catalog sync from Workspace → Products → Sync
Última modificação em 12 de março de 2026