> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# clickAnalytics

> Whether to compute a query ID for the current query

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="boolean" default="false" scope="search" />

The `clickAnalytics` parameter determines, if the response includes a `queryID`
parameter for linking click and conversion events to searches.
This query ID is required for all [events related to a search](/doc/guides/sending-events/concepts/event-types).

For more information about sending events, see [Click and conversion events](/doc/guides/sending-events).

## Usage

Setting `clickAnalytics` to `true` doesn't add any new analytics data.
It only ensures that the `queryID` is generated and added to the search response.
You have to pass this `queryID` when sending search-related events to the Insights API.

## Example

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SearchSingleIndexAsync<Hit>(
        "INDEX_NAME",
        new SearchParams(new SearchParamsObject { ClickAnalytics = true })
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          clickAnalytics: true,
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
        "INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
        search.NewEmptySearchParamsObject().SetClickAnalytics(true))))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex("INDEX_NAME", new SearchParamsObject().setClickAnalytics(true), Hit.class);
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({ indexName: 'indexName', searchParams: { clickAnalytics: true } });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = SearchParamsObject(clickAnalytics = true),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['clickAnalytics' => true,
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "clickAnalytics": True,
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(click_analytics: true)
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = Some(
            SearchParamsObject(
              clickAnalytics = Some(true)
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response: SearchResponse<Hit> = try await client.searchSingleIndex(
          indexName: "INDEX_NAME",
          searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(clickAnalytics: true))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.Search(
        new Query("query") {
          ClickAnalytics = true
        }
      );
      ```

      ```go Go theme={"system"}
      index.Search(
      	"query",
      	opt.ClickAnalytics(true),
      )
      ```

      ```java Java theme={"system"}
      index.search(
        new Query("query")
          .setClickAnalytics(true)
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .search("query", {
          clickAnalytics: true,
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```php PHP theme={"system"}
      $res = $index->search('query', [
        'clickAnalytics' => true
      ]);
      ```

      ```python Python theme={"system"}
      res = index.search("query", {"clickAnalytics": True})
      ```

      ```ruby Ruby theme={"system"}
      results = index.search(
        "query",
        {
          clickAnalytics: true
        }
      )
      ```

      ```swift Swift theme={"system"}
      let query = Query("query")
        .set(\.clickAnalytics, to: true)

      index.search(query: query) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
