Two Integration Paths
| Path | Best for | File |
|---|---|---|
| Liquid snippet | Online Store 2.0 themes (standard) | alana-predictive-search.liquid |
| Hydrogen component | Headless Hydrogen storefronts | AlanaSearch.tsx |
Option A: Liquid Snippet (Online Store 2.0)
Step 1 — Add the snippet
Copyalana-predictive-search.liquid to your theme’s snippets/ directory via the Shopify Admin theme editor or CLI:
Step 2 — Configure API credentials
In Shopify Admin → Online Store → Themes → Customize → Theme Settings, add:| Setting | Value |
|---|---|
alana_api_key | Your ak_xxx API key |
alana_api_url | https://app.alana.shopping |
config/settings_data.json:
Step 3 — Render the snippet
In your theme’s search template (e.g.,sections/predictive-search.liquid or the search form partial), add:
- Finds
input[type="search"],input[name="q"], or#Search-In-Template - Attaches autocomplete to the input
- Intercepts form submit to call Alana search
- Renders results in
#alana-results-container
What the Liquid snippet provides
- Autocomplete dropdown on keypress (200ms debounce)
- Full search results grid on form submit
- Spell correction suggestion with click-to-search
detail-page-viewevent on product card click- Persistent visitor ID via
localStorage
Option B: Hydrogen Component (Headless)
Step 1 — Copy the component
Step 2 — Use in a route
Component props
| Prop | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your Alana search API key |
apiUrl | string | https://app.alana.shopping | API base URL |
hitsPerPage | number | 20 | Results per search |
placeholder | string | Search products... | Input placeholder text |
Environment variable pattern
Store the API key in.env:
Security Notes
- Use a search-only API key — never a service-role key
- The Liquid snippet exposes
window.AlanaShopifyas a frozen object (Object.freeze) to prevent prototype pollution - All HTML from the Alana API (highlight snippets) is sanitized to
<em>and<mark>tags only before rendering