When Piwik PRO tracks an internal search, it grabs a piece of a URL address with query parameters like q
, query
, s
, search
, searchword
, and keyword
. If you’re using different query parameters then you can add them to the internal search settings, and the tracking will work fine (Menu > Administration > Sites & apps > Select a site or app
> Data collection > Keywords from your internal search engine).
But in some cases, a URL address doesn’t store query parameters, and then you need to use a JavaScript function to record and send internal search data.
Note: You can also use this method to track a search category and count of search results.
To track internal search with JavaScript function, follow these steps:
- On the page with search results, before
_paq.push(['trackPageView']);
use the following function:_paq.push(['trackSiteSearch','keyword','category','search_count']);
- You may use variables in Tag Manager to capture each piece of information — keyword, category, and search count.
- If you have variables, add them to the function:
_paq.push(['trackSiteSearch',{keyword_variable},{category_variable},{search_count_variable}]);
For developers: For more information about internal search tracking, read our developer guide.