Search Key Words - How does it work?


(JL) #1

From the PIWIK GUI, there is a site search feature that lists the search key words. We would like to query the PIWIK database tables to get the same information so that they can be presented on a different reporting tool. I see in the piwik_log_action table, the name column contains the search keywords, which has type = 8. I don’t see any article on how this works behind the scene. I have a SharePoint Online site collection, when searching, the search keyword does not get stored in the piwik_log_action table.


(Lukas Winkler) #2

Hi,

I’d rather recommend you to use the HTTP API to fetch this data.

There you can simply use the Actions.getSiteSearchKeywords endpoint.

https://demo.matomo.org/?module=API&method=Actions.getSiteSearchKeywords&idSite=62&period=day&date=today&format=JSON&token_auth=anonymous

Keep in mind that many search engines don’t specify the keyword in the referrer anymore.


(JL) #3

Thanks Lukas for your reply. The Actions.getSiteSearchKeywords DOES work! However, the problem is that (some) search key words are not captured. We are using Microsoft SharePoint Online. There is a textbox for entering key word and a search button, when the search button is clicked, it goes to SharePoint Search to displayed the search results. I would like to know how PIWIK identify when a button is clicked, it is doing a search but not other things such as submitting a web form.


(Lukas Winkler) #4

Maybe this helps:
https://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking


(JL) #5

I found that the search keywords are not recorded. Our system is query string ?k= for search in URL. What I found is that not all page views are tracked by PIWIK. I keep visiting the site, I can see other users’ visits are tracked in PIWIK, but some are not. For my visits, it was tracked on one day, but not the others. Very strange.


(Naser Aslam) #6

Sometime google chrome (or other browsers) save cache so from such browsers tracking is not saved in Matomo. But if you use chrome in incognito (private mode) or Mozila Firefox then your tracking will get display on Matomo. Thanks.


(Lukas Winkler) #7

Hi @Naser_Aslam,

If tracking requests to matomo.php/piwik.php are cached for you, then there is something wrong with your server config as dynamic PHP requests should never be cached.