@KarthikRaja1388 opened this Issue on July 30th 2019

In Site Search, part of keyword is getting ignored/truncated, when there is an ampersand (&) in the keyword (ex: Heatmap & session recording)

Expected: Report should contain the word "Heatmap & session recording"

Result: Can only see "Heatmap" in Visits log and also the Site Search report

Steps to reproduce:

  1. Search for "Heatmap & session recording"
  2. check the Visits Log and Site Search

Example site search:
site search error

Visits log:
site serach error visits log

@mattab commented on July 31st 2019 Member

In the meantime we can offer a workaround. The workaround is to manually call trackSiteSearch and replace manually your ampersand by another character. The steps to implement the workaround would be:

1) do not call trackPageView on your search results page
2) instead On your search result page, you would call piwikTracker.trackSiteSearch(keyword, category, searchCount) function to record the internal search request. Note: the 'keyword' parameter is required, but category and searchCount are optional.

_paq.push(['trackSiteSearch',
// Search keyword searched for
"Banana", // Here you want to replace & by another character
// Search category selected in your search engine. If you do not need this, set to false
"Organic Food",
// Number of results on the Search results page. Zero indicates a 'No Result Search Keyword'. Set to false if you don't know
0
]);
// We recommend not to call trackPageView() on the Site Search Result page
// _paq.push(['trackPageView']);

We also recommend to set the searchCount parameter, as Matomo will specifically report "No Result Keywords", ie. Keywords that were searched, but did not return any result. It is usually interesting to know what users search for but can't find (yet?) on your website.

3) Replace ampersand by another character in the keyword in trackSiteSearch
// Here you want to replace & by another character

See the JS site search tracking doc in: https://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking

Powered by GitHub Issue Mirror