trackSiteSearch

The trackSiteSearch() method tracks searches on your internal search engine.

Syntax

trackSiteSearch(keyword, category, resultCount, dimensions)
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void
trackSiteSearch(keyword, category?, searchCount?, dimensions?): void

Parameters

ParameterTypeDescriptionRequired
keywordstringThe keyword the visitor typed into the search box.Yes
categorystring | array<string>The category selected in the search engine.No
searchCountnumberThe number of search results.No
dimensionsobjectA list of custom dimensions you want to pass with this event. Format for keys: dimensionX where X is the dimension ID. Format for values: percent-encoded (Use the encodeURIComponent() method to encode strings.)No

Examples

To send an internal search with the keyword "ATM in London" and 20 search results:

_paq.push(["trackSiteSearch", "ATM in London", undefined, 20]);
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void
trackSiteSearch("ATM in London", undefined, 20, dimensions?): void

To send an internal search with variables:

_paq.push(['trackSiteSearch',{keyword_variable},{category_variable},{search_count_variable}]);
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void
trackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): void

Notes

  • If you can’t or don’t want to rely on automatic site search detection from URL parameters, call the trackSiteSearch() method instead of trackPageView() on the search results page. Using both methods may result in duplicate site search events.