Site search with query string parameter "?q=" doesn't track page views

Hello everyone.

We’re having an issue with page tracking on a site.

This site is a search site just like Google.
On this site we have three pages, each page is dedicated to one category such as: “web results”, “documents” and “organizations”.
We would like to know how many visitors each page has. The problem is that piwik doesn’t seem to track page views under “Actions/Pages” if the parameter “q” exists in the query string.

Lets say someone searches for “pizza pie”:
?q=pizza+pie

This will log a site search but not a page view.

If we exclude the query paramter:
?q=

It will log a page view.
Is it possible to get both?

Thanks in advance!

Hi there,
Well the easiest here would be to have the website. Could you please just indicate us the URL. I guess it is either a # issue or the fact that the pages do not have the tracking code.
That should be quite easy to do.

Yes of course, the site is Sök - Webb
The page view tracking works as normal so long as the q parameter is missing. :slight_smile:

Yes that’s weired, probably @Findus23 will have an idea. I have the feeling too that there is something wrong but I cannot know what yet.

Hi,

It took me a while to understand how you have embedded the tracking script. Unfortunatly I can’t find a difference between the search site you liked and the home page. The tracking request is sent to piwik and returns success (200)

http://piwik.vgregion.se/piwik.php?action_name=S%C3%B6k%20-%20Webb&idsite=122&rec=1&r=868826&h=17&m=44&s=24&url=http%3A%2F%2Fhitta.vgregion.se%2Fwebb%2F%3Fq%3Dsallad%2B%C3%A4r%2Bnyttigare%26d%3D%26c%3D&_id=8011500fe8238ca4&_idts=1503934977&_idvc=1&_idn=0&_refts=0&_viewts=1503934977&send_image=1&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=0&java=0&gears=0&ag=0&cookie=1&res=1920x1080&gt_ms=278&pv_id=k42uFp

You can try out enabling the debug mode for the tracker and see if an error occurs, but otherwise I am out of ideas.
https://developer.piwik.org/api-reference/tracking-api#debugging-the-tracker

I didn’t realize that the home page logged both page views and search queries…
When we enabled debug mode the request to piwik time out (we have quite a few sites using piwik). So we couldn’t get any more info from that, but it was a good idea to try.

I’ve also tired to strip the page of all html content, still no success.
What I’m thinking as a workaround is to log page views twice for our search pages.

    _paq.push(['trackPageView']);

    _paq.push(['setCustomUrl', location.protocol + '//' + location.host + location.pathname]); // This will return the URL without any parameters
    _paq.push(['trackPageView']);

That will be good enough. Thanks for your help!