Embed options
For developers. This page lists every attribute the install snippet reads and the JavaScript API of
the running widget. Put attributes on the loader.js script tag: the loader hands them to the search
widget and to the AI Assistant.
<script src="https://search.typemo.com/loader.js?k=YOUR_API_KEY" data-target-element="#search-button" data-locale="de" async></script>Script attributes
Section titled “Script attributes”| Attribute | Values | Default | What it does |
|---|---|---|---|
data-target-element | A CSS selector starting with #, . or [, or a bare ID | None | A click on a matching element opens the search. Hover or focus loads its data early. Every match on the page is connected |
data-search-input | A CSS selector | Your search field on Search → Look | The site’s own search field: on a computer the Catalog widget opens under it, the field its search box (over the page with Search in your field off); on phones search opens over the page from it (a Docs widget: Under the field). Wins over the dashboard’s for this page |
data-ai-trigger | The same as above | None | A click on a matching element opens or closes the AI Assistant’s chat, without the search. Works while the assistant is on. See Your own Ask AI button |
data-placeholder | Text | Search placeholder on Search → Look | The text in the empty search box |
data-locale | A language code, such as de or de-DE | Language on Search → Look | The language of the search widget and the assistant’s interface. An unsupported code shows English. See Languages and currency |
data-default-collection | A collection ID | The first tab under Search → Look → Tabs | The tab the widget opens on. An ID that isn’t one of the widget’s tabs is ignored. A visitor who picked another tab gets their tab back |
data-start-open | true | Closed | Opens the search as soon as the page loads |
data-show-facets | false | Shown | Catalog widget: hides the filters |
data-show-add-to-cart | true or false | Add to cart button on Search → Look | Catalog widget: shows or hides the cart button on cards |
data-disable-url-state | true | Off | Catalog widget: stops writing the search into the page address, and stops opening a search from a link |
data-primary-color | A CSS colour | None | An older way to set the accent. In the search widget it wins over Accent; in the assistant’s chat Accent wins. Prefer --typemo-brand |
data-debug | true | Off | Logs a line to the console when the widget starts |
| Case | Behaviour |
|---|---|
true and false values | Most switches turn on only with exactly true. data-show-facets and data-show-add-to-cart count any value but false as on |
| An attribute that sets something on Search → Look | The attribute wins on that page, except data-primary-color in the assistant’s chat |
| The API key | It goes only in the k= of the src. A data-api-key attribute is ignored |
| Changing an attribute after the page loaded | Nothing happens: attributes are read once, when the widget starts. Use typemo('init', …) below |
An element data-target-element matches that appears later | It isn’t connected. Call open() from its click handler instead |
JavaScript API
Section titled “JavaScript API”Each script the snippet loads creates one global instance, once it has finished loading.
| Global | What it is |
|---|---|
window.typemoInstance | The catalog widget |
window.typemoDocsInstance | The docs widget |
window.typemoAssistant | The AI Assistant. Its methods are on Your own Ask AI button |
Methods of the search widget
Section titled “Methods of the search widget”| Method | What it does |
|---|---|
open(collectionId?) | Opens the search. The docs widget opens on collectionId when it is one of its tabs; the catalog widget ignores it |
close() | Closes the search |
openChat() | Opens the AI Assistant’s chat with the search closed. Does nothing while the assistant is off |
prefetch() | Loads the widget’s data before the first open, as hovering the trigger does |
trackAddToCart(collectionId, docId) | Reports a cart add made outside the widget, such as on the product page a result led to. The product then counts as found through search |
getAttributedDocIds(collectionId) | Returns the IDs of the products this visitor clicked or added through the widget in the last 48 hours |
trackPurchase(collectionId, docId, value, currency) | Reports one purchased item: value is what was paid for it, currency a code such as EUR |
clearAttribution(collectionId) | Forgets the remembered products, so the next order starts fresh |
destroy() | Removes the widget from the page |
Events shows the purchase methods together on an order confirmation page.
Configure from code
Section titled “Configure from code”typemo('init', config) replaces the running search widget and AI Assistant with new ones built from
config. The script tag’s attributes are not merged in, so pass everything you need, apiKey
included. Call it from a script after the snippet; the first two lines queue the call until the
loader is ready:
<script src="https://search.typemo.com/loader.js?k=YOUR_API_KEY" async></script><script> window.TypemoQueue = window.TypemoQueue || []; window.typemo = window.typemo || function () { window.TypemoQueue.push(arguments); };
typemo('init', { apiKey: 'YOUR_API_KEY', targetElement: '#search-button', defaultSort: 'price_asc', cssVariables: { brand: '#d84315' } });</script>| Option | Type | What it does |
|---|---|---|
apiKey | string | Required. The key from the snippet’s k= |
targetElement, aiTrigger, placeholder, locale, defaultCollection, primaryColor | string | As the attributes above |
startOpen, showFacets, showAddToCart, disableUrlState, debug | boolean | As the attributes above |
cssVariables | object | Theme variables by name, without --typemo-: { brand: '#d84315' }. When set, the colours from Search → Look are not applied. Themes the assistant’s chat too |
customCss | string | CSS applied inside the widget and the assistant’s chat, after Custom CSS from Search → Look. See Parts |
defaultSort | 'relevance', 'price_asc', 'price_desc' | Catalog widget: the order a search starts in. Needs a column mapped as Price |
popularSearches | string array | Replaces the popular searches the widget shows, up to eight |
onSelect(result) | function | Called when a visitor opens a result, before the widget follows its link |
onAddToCart(product) | function | Catalog widget: called on a cart press in the results, with the same product as typemo:add-to-cart |
Next: Events to connect the cart, or Theming with CSS.