trackSiteSearch
The trackSiteSearch() method tracks searches on your internal search engine.
Syntax
trackSiteSearch(keyword, category, resultCount, dimensions)trackSiteSearch(keyword, category?, searchCount?, dimensions?): voidtrackSiteSearch(keyword, category?, searchCount?, dimensions?): voidtrackSiteSearch(keyword, category?, searchCount?, dimensions?): voidtrackSiteSearch(keyword, category?, searchCount?, dimensions?): voidtrackSiteSearch(keyword, category?, searchCount?, dimensions?): voidtrackSiteSearch(keyword, category?, searchCount?, dimensions?): voidParameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| keyword | string | The keyword the visitor typed into the search box. | Yes |
| category | string | array<string> | The category selected in the search engine. | No |
| searchCount | number | The number of search results. | No |
| dimensions | object | 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.) | 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?): voidtrackSiteSearch("ATM in London", undefined, 20, dimensions?): voidtrackSiteSearch("ATM in London", undefined, 20, dimensions?): voidtrackSiteSearch("ATM in London", undefined, 20, dimensions?): voidtrackSiteSearch("ATM in London", undefined, 20, dimensions?): voidtrackSiteSearch("ATM in London", undefined, 20, dimensions?): voidTo 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?): voidtrackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): voidtrackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): voidtrackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): voidtrackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): voidtrackSiteSearch({keyword_variable},{category_variable},{search_count_variable}, dimensions?): voidNotes
- 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 15 days ago