Site search: measure internal searches
Your site's search box is a direct line to what visitors want. Two small events show what they look for, and what they cannot find.
Three events, one pattern
Search measurement is built on three events. The first two are the foundation, the third is optional and unlocks search CTR.
| Event | When to send it |
|---|---|
| site_search | On every completed search, regardless of the number of results. |
| site_search_zero | When a search returns 0 results. Sent in addition to site_search. |
| site_search_click | When the visitor clicks a search result. Optional, enables search CTR. |
Step 1: register properties
Properties must be registered before they are stored. Register query under Settings, Properties in the dashboard, and preferably results_count and source.
| query | The search phrase, normalized: lowercase and trimmed. |
| results_count | Number of results the search returned. |
| source | Where the search happened: autocomplete or results page. |
Unregistered properties are silently dropped on ingest. The events are still counted, but the phrases will be missing in the view.
Step 2: send the events
Send site_search on every completed search. If the search returns 0 results, also send site_search_zero.
// On every search
va('event', 'site_search', {
query: 'soffbord ek',
results_count: 12,
source: 'resultatsida'
});
// On 0 results, send both events
va('event', 'site_search_zero', {
query: 'soffbord ekk',
source: 'resultatsida'
});Step 3 (optional): measure search CTR
Send site_search_click when the visitor clicks a search result. The view can then compute search CTR, the share of searches that lead somewhere.
// On a search result click
va('event', 'site_search_click', {
query: 'soffbord ek',
source: 'resultatsida'
});Note: autocomplete and keystrokes
An autocomplete that searches while the visitor types easily sends one event per keystroke. Prefer sending the event when the visitor pauses (debounce, about 500 ms) or when the search is committed. The view can collapse prefix variants, but the data is cleaner if the noise is never sent.
How to read the view
The Site search view lives per site in the dashboard and shows the last 90 days.
- • The zero-results list is your action list: phrases visitors look for but do not find. Fill the gaps with products, synonyms or content.
- • Zero rate is the share of searches with no results. Below 20% is good, above 40% suggests gaps in your catalog or a too strict search engine.
- • The top searches show what visitors look for most often. Compare with what your site highlights on the start page and in menus.
- • Search CTR appears once site_search_click is sent: the share of searches that lead to a click on a result.
Tips
Normalize the phrase before sending it: lowercase and trimmed whitespace. That way different spellings of the same phrase group together in the lists.
Let AI do the work
Copy the prompt and give it to your AI assistant together with the code for your search feature.