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
keyword (string, required)
The keyword the visitor typed into the search box.
category (string | array, optional)
The category selected in the search engine.
searchCount (number, optional)
The number of search results.
dimensions (object, optional)
A 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.)
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.
Updated 6 days ago