Skip to content

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>
AttributeValuesDefaultWhat it does
data-target-elementA CSS selector starting with #, . or [, or a bare IDNoneA click on a matching element opens the search. Hover or focus loads its data early. Every match on the page is connected
data-search-inputA CSS selectorYour search field on Search → LookThe 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-triggerThe same as aboveNoneA 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-placeholderTextSearch placeholder on Search → LookThe text in the empty search box
data-localeA language code, such as de or de-DELanguage on Search → LookThe language of the search widget and the assistant’s interface. An unsupported code shows English. See Languages and currency
data-default-collectionA collection IDThe first tab under Search → Look → TabsThe 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-opentrueClosedOpens the search as soon as the page loads
data-show-facetsfalseShownCatalog widget: hides the filters
data-show-add-to-carttrue or falseAdd to cart button on Search → LookCatalog widget: shows or hides the cart button on cards
data-disable-url-statetrueOffCatalog widget: stops writing the search into the page address, and stops opening a search from a link
data-primary-colorA CSS colourNoneAn 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-debugtrueOffLogs a line to the console when the widget starts
CaseBehaviour
true and false valuesMost 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 → LookThe attribute wins on that page, except data-primary-color in the assistant’s chat
The API keyIt goes only in the k= of the src. A data-api-key attribute is ignored
Changing an attribute after the page loadedNothing happens: attributes are read once, when the widget starts. Use typemo('init', …) below
An element data-target-element matches that appears laterIt isn’t connected. Call open() from its click handler instead

Each script the snippet loads creates one global instance, once it has finished loading.

GlobalWhat it is
window.typemoInstanceThe catalog widget
window.typemoDocsInstanceThe docs widget
window.typemoAssistantThe AI Assistant. Its methods are on Your own Ask AI button
MethodWhat 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.

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>
OptionTypeWhat it does
apiKeystringRequired. The key from the snippet’s k=
targetElement, aiTrigger, placeholder, locale, defaultCollection, primaryColorstringAs the attributes above
startOpen, showFacets, showAddToCart, disableUrlState, debugbooleanAs the attributes above
cssVariablesobjectTheme variables by name, without --typemo-: { brand: '#d84315' }. When set, the colours from Search → Look are not applied. Themes the assistant’s chat too
customCssstringCSS 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
popularSearchesstring arrayReplaces the popular searches the widget shows, up to eight
onSelect(result)functionCalled when a visitor opens a result, before the widget follows its link
onAddToCart(product)functionCatalog 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.