> For the complete documentation index, see [llms.txt](https://docs.nosto.com/techdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/techdocs/implementing-nosto/implement-search/search/implement-autocomplete-using-library/initialization/submit-search.md).

# Submit search

When submitting Search results through Autocomplete, `submit` callback is called on these events:

* **`Enter` key press.**
* **`Submit button` click.**
* **`Keyword` click.**

By default `submit` checks if query/keyword length satisfies `minQueryLength`, sends `Search Submit event` to Nosto Analytics, and sends Search request to the Nosto Search API.

In the usual scenario, you want to render Search Results on submit, so you should override `submit` function:

```javascript
submit: async (query, config, options) => {
    if (
        query.length >= config.minQueryLength
    ) {
        const response = await search(
            {
                query,
            },
            {
                redirect: true,
                track: config.nostoAnalytics ? "serp" : undefined,
                ...options
            }
        )
        // Do something with response. For example, update Search Engine Results Page products state.
    }
},
```

To disable `submit` pass `undefined` value.\
\\

#### 📊 Nosto Analytics (enabled by default)

Setting `nostoAnalytics: true` will enable Nosto Analytics tracking. Tracking results can be seen in the Nosto Dashboard under Search & Categories -> Analytics page.

{% hint style="info" %}
Note: You should additionally add click events on your search results page according to [Nosto Tech Docs](/techdocs/implementing-nosto/implement-search/search.md#search-product-click) with `type: serp || category` according to the results page type.
{% endhint %}

#### 📈 Google Analytics (enabled by default)

By default, we send `pageview` events to existing GA tag, found in shop site. To send `pageview` events with correct search information, a minimal configuration is needed in `googleAnalytics` property.

* **`serpPath`** - Search query url parameter name
* **`queryParamName`** - Search query url parameter name
* **`enabled`** - Enable Google Analytics

For example, if search results URL is <https://examplenostoshop.com/search-results?query=shoes>, then configuration should be:

```javascript
googleAnalytics: {
    serpPath: "search-results",
    queryParamName: "query",
    enabled: true
}
```

To disable Google Analytics, set `googleAnalytics: false`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nosto.com/techdocs/implementing-nosto/implement-search/search/implement-autocomplete-using-library/initialization/submit-search.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
