Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript site search reports results count from previous search #7816

Closed
kevinb456 opened this issue May 3, 2015 · 11 comments
Closed

javascript site search reports results count from previous search #7816

kevinb456 opened this issue May 3, 2015 · 11 comments
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@kevinb456
Copy link

I am using Piwik 1.12.1 with opencart 2.0.2 , using the default site search query parameters which Piwik automatically gets the keywords from, then adding the count into the javascript footer as follows (as recommended on piwik documentation);

_paq.push(['setCustomUrl', document.URL + '&search_count=x']);

where x is the count value rendered by PHP for that results page.

When on a search results page for a product, with say 4 results, the javascript source correctly has "search_count=4" in it. However when I view the site search in Piwik the results count reported is not 4, but whatever number the previous site search had.

I can't think of anything I'm doing wrong so I'm assuming this is Piwiks bug. Happy to be proven wrong!

@tsteur
Copy link
Member

tsteur commented May 3, 2015

Can you try with latest Piwik version? We do no longer support Piwik 1.X

@kevinb456
Copy link
Author

Sorry, typo, I'm using 2.12.1!

@tsteur
Copy link
Member

tsteur commented May 5, 2015

I just tried to reproduce and thought I can but then I noticed there was a problem with my URL.

Is it possible that you use fragments in the URL? Such as http://example.org?query=test&search_count=45#&search_count=42? Sending http://example.org?query=test#45&search_count=42 should be OK though as we concatenate the query part and the fragment part. It might have other side effects though. The search_count in fragment takes in general precedence over the search_count in the query part.

Can you also make sure it is not a problem in PHP? Eg can you check in the browser that the actual correct value is set in the HTML/JavaScript?

@kevinb456
Copy link
Author

No, no URL fragments. To illustrate further I've just done a test with the default Opencart 2.0.2.0 store (fresh install) and Piwik 2.12.1 as mentioned. I tried searching for 'mac' (4 results) then 'iphone' (1 result) then 'ipod' (4 results). The search URL is of the form index.php?route=product/search&search=ipod. Piwik then picks up correctly on the &search= term.

However what I see in the Piwik visitor log is the first search 'mac' which should be 4 results, not show a result count figure at all, 'iphone' which should be 1 shows a results count of 4, and 'ipod' which should be 4 shows a results count of 1. See below when hovering over 'ipod' search;

image

Yes its definitely not a PHP issue, e.g. on the final search results page for 'ipod' with four results this is the piwik javascript in the HTML source;

<!-- Piwik --><script type="text/javascript"> var _paq = _paq || []; _paq.push(["setEcommerceView",productSKU = false,productName = false,categoryName = false,price = false]); _paq.push(['setCustomUrl', document.URL + '&search_count=4']); _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u=(("https:" == document.location.protocol) ? "..." : "..."); _paq.push(["setTrackerUrl", u+"piwik.php"]); _paq.push(["setSiteId", "1"]); var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); })();</script><!-- End Piwik Code -->

@tsteur
Copy link
Member

tsteur commented May 12, 2015

I'm trying to reproduce this already for a while and might think this could be a JavaScript issue somewhere here: https://github.com/piwik/piwik/blob/2.13.1/plugins/Live/javascripts/visitorLog.js#L43

I noticed kinda a similar issue. I had 3 searches under the same action, but they were grouped in JS so only the last search result was shown in the tooltip (or the first one not sure)

visitorlog_search

@tsteur
Copy link
Member

tsteur commented May 12, 2015

It's actually because we use the pageTitle for siteSearchKeyword. Can anyone confirm this is on purpose? https://github.com/piwik/piwik/blob/2.13.1/plugins/Live/Visitor.php#L290 This code been there already for a long time. This causes the page title to be displayed here: https://github.com/piwik/piwik/blob/2.13.1/plugins/Live/templates/_actionsList.twig#L88

@mattab ?

@mattab
Copy link
Member

mattab commented Jul 15, 2015

@tsteur whatever is done should be on purpose, but if it causes this bug, something needs to be fixed :-) let's take a look at it for 2.15.0

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Jul 15, 2015
@mattab mattab added this to the 2.15.0 milestone Jul 15, 2015
@tsteur
Copy link
Member

tsteur commented Aug 7, 2015

FYI: Deleted 2 comments as they belong to a different issue

@tsteur tsteur self-assigned this Aug 7, 2015
@tsteur
Copy link
Member

tsteur commented Aug 7, 2015

I tried to reproduce for quite a while but couldn't. I also debugged the part from fetching the visitors from DB to displaying them in the UI and everything seems to be straight forward. So the only thing where something could go wrong would be the tracker but I kinda doubt that this is the problem.

Can you maybe send us a link to your website and maybe a few steps to reproduce? Maybe it helps us to reproduce. If so, feel free to send us an email to "hello at piwik.org" then comment here (just in case the mail goes into spam).

@tsteur tsteur removed their assignment Aug 7, 2015
@mattab
Copy link
Member

mattab commented Aug 9, 2015

Thanks @tsteur for investigating

@kevinb456 hopefully you can send us more information, we may not be able to fix it otherwise.

@mattab
Copy link
Member

mattab commented Aug 14, 2015

Closing, @kevinb456 feel free to re-open and post more information. thx

@mattab mattab closed this as completed Aug 14, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Aug 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants