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

# analyticsTags

> Tags for the current query to segment your analytics data

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="list<string>" default="[]" scope="search" />

The `analyticsTags` parameter lets you assign custom tags to a search query.
These tags are used to segment and analyze your search traffic in [Algolia Analytics](/doc/guides/search-analytics/guides/segments).

For example, you can apply different tags such as `"mobile"` or `"desktop"` to compare behavior across platforms.

## Usage

* Each tag can be up to **100 characters**. Tags longer than that are ignored.
* Tags that start with `alg#` are reserved and will be ignored.
* You can assign up to **10 tags per query**.
* You can use up to **1,750 unique tag combinations every 5 minutes**.\
  Additional combinations are ignored.
  For example, `"ios"`, `"en"`, and `"ios,en"` count as three combinations.

## 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 { AnalyticsTags = new List<string> { "YOUR_ANALYTICS_TAG" } }
        )
      );
      ```

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

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

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex(
        "INDEX_NAME",
        new SearchParamsObject().setAnalyticsTags(Arrays.asList("YOUR_ANALYTICS_TAG")),
        Hit.class
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: { analyticsTags: ['YOUR_ANALYTICS_TAG'] },
      });
      ```

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

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

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "analyticsTags": [
                  "YOUR_ANALYTICS_TAG",
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(analytics_tags: ["YOUR_ANALYTICS_TAG"])
      )
      ```

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

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

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.Search(new Query("")
      {
          AnalyticsTags = new List
          {
              "front_end",
              "website2"
          },
      });
      ```

      ```go Go theme={"system"}
      res, err := index.Search(
      	"query",
      	opt.AnalyticsTags("front_end", "website2"),
      )
      ```

      ```java Java theme={"system"}
      index.search(
        new Query("query")
          .setAnalyticsTags(
            Arrays.asList(
              "front_end",
              "website2"
            )
          )
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .search("query", {
          analyticsTags: ["front_end", "website2"],
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val query = query("query") {
          analyticsTags {
              +"front_end"
              +"website2"
          }
      }

      index.search(query)
      ```

      ```php PHP theme={"system"}
      $results = $index->search('query', [
        'analyticsTags' => [
          'front_end',
          'website2'
        ]
      ]);
      ```

      ```python Python theme={"system"}
      results = index.search("query", {"analyticsTags": ["front_end", "website2"]})
      ```

      ```ruby Ruby theme={"system"}
      results = index.search(
        "query",
        {
          analyticsTags: [
            "front_end",
            "website2"
          ]
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        search into "myIndex" query Query(
          query = Some("query"),
          analyticsTags = Some(Seq(
            "front_end",
            "website2"
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      let query = Query("query")
          .set(\.analyticsTags, to: ["front_end", "website2"])

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