Posted by jmesam on October 24, 2009 at 6:33pm
Jump to:
| Project: | Google Analytics |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Justin Cutroni propose a way to track searches that don’t produce any results:
http://www.epikone.com/blog/2009/09/08/tracking-ero-result-searches-in-g...
Comments
#1
Interesting... and the most difficult part will be to get out if there are search results or not.
Please provide a patch.
#2
This is very specific to themes... not sure how to solve. Aside you can implement it with custom javascript before and after snippets... it would only looks not very nice :-(. At least "sn" and the regex need to be changed for Drupal... 'content' ID may be unavailable in a theme and 'Your search yielded no results' may be translated and a bit more issues...
Snippet (Before):
var content = document.getElementById('content');if (content.innerHTML.search('Your search yielded no results')) {
// These lines get the search data from the URL and
// deconstruct the URL into parts
var sn = "s";
var sr = new RegExp(sn+"=[^\&]+"),
p = document.location.pathname,
s = document.location.search,
sm = s.match(sr).toString(),
srs = sm.split("="),
// The next line is where we add the category and add
// the phrase no-results to the search term.
sre = sm.replace(sr,srs[0]+"=no-results: "+srs[1]+"&cat=no-results"),
sf = s.replace(sr,sre);
// Send the data to Google as a Pageview
pageTracker._trackPageview(p+sf);
} else {
// If this is a regular page on the site, use the standard GA code.
Snippet (After):
}#3
I see, there's not a easy way on drupal :(
Thanks for the code
#4
As said - this *hardly* depends on theme HTML code. I have no idea how to implement this in a generic way if core does not provide us the number of found results in a hook or via a function calll :-(. If someone is able to come up with a way I would be happy to implement this.
#5
Let's investigate if there is a way in D7...
#6
Found something, but need to dig deaper... And do some testing
http://api.drupal.org/api/drupal/modules--search--search-results.tpl.php... with
Your search yielded no results.http://api.drupal.org/api/drupal/modules--search--search.pages.inc/funct...
#7
Implemented search result counter in piwik successfully. Can be ported, but I would also be interested to always get the results and not only if there is no result.
#8
Committed to D6 and D7
#9
Automatically closed -- issue fixed for 2 weeks with no activity.