After feature http://dev.piwik.org/trac/ticket/49 has been implemented in Piwik we should add it, too.

Comments

hass’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Postponed » Fixed
hass’s picture

Also backported to D6 and D5

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

haggins’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Active

Great feature!
Has anyone got it working with custom_search module? It uses another url like
h**p://example.com/?q=search/node/my%20search%20pattern

hass’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Closed (fixed)

Url Looks good. Must work

haggins’s picture

Category: feature » support
Status: Closed (fixed) » Active

But sadly it does not. I tried both "query" and "node" as search parameter with "search" as search-url. However piwik doesn't find any.

haggins’s picture

To get any results I had to modify SiteSearchs SiteSearch.php:

public function logResults($notification) {
  // ...
			$actionUrl = $action->getActionUrl();
			$actionName = $action->getActionName();
			if (substr($actionUrl, 0, strlen($url)) == $url) {
				Piwik_SiteSearch_Archive::logAction(array(
					'idaction' => ($idaction),
					'name' => $actionName // instead of $actionUrl because only at the actions name we an url like "search?query=cherry"
				), $site['idsite'], $site, $resultCount);
				
			}
		}
}

Oddly I got no search tracking though.

After further debugging it looks as the problem occurs because piwik SiteSearch plugin misses the "data" parameter:

plugins/SiteSearch/SiteSearch.php

public function logResults($notification) {
		$action = $notification->getNotificationObject();
		$idaction = $action->getIdActionUrl();

		// search results
		$data = Piwik_Common::getRequestVar('data', '');
		$data = html_entity_decode($data);
		$data = json_decode($data, true); // empty!

		$resultCount = false; // simulating 5 results by setting $resultCount = 5; works pretty fine!
		if (isset($data['SiteSearch_Results'])) {
			$resultCount = intval($data['SiteSearch_Results']);
		}
		// ...
}

In further processing this happens:
plugins/SiteSearch/Db.php

	public static function replaceBinding(&$matches) {
		$name = $matches[0];
		$newBinding = false;
		if (isset(self::$bindings[':'.$name])) {
			$newBinding = self::$bindings[':'.$name];
		} else if (isset(self::$bindings[$name])) {
			$newBinding = self::$bindings[$name];
		}
		if (!$newBinding) { // $newBinding = false/0
			throw new Exception('Invalid binding name "'.$name.'"');
		}
		
		self::$newBindings[] = $newBinding;
		return '?';
	}

I'm wondering how the plugin wants to track search terms without any results since $resultCount will be 0 and the same expeption will be thrown.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

I cannot speak for the search plugin, but piwik implemented it in a way that the search plugin should be able to collect the data. Maybe the maintainer of the search stuff can help here. I really hope it goes into piwik core very soon... at least it is marked as "experimental" :-)

haggins’s picture

I created an issue on github: https://github.com/BeezyT/piwik-sitesearch/issues/issue/26
Hope we get it working ;)

hass’s picture

Status: Postponed (maintainer needs more info) » Fixed

As I may not able to solve this bug, I'm cleaning up the issue queue now.

Nevertheless I'm interested if you managed to get this issue solved?

haggins’s picture

No, sadly I didn't find any solution yet. This is still an interesting feature, but I've got no free ressources to dive deeper here atm. If I find a solution I will share it here, of course!

Were you able to reproduce the issue?

hass’s picture

No sorry, no time.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hass’s picture

Category: support » task
Status: Closed (fixed) » Postponed
hass’s picture

Status: Postponed » Fixed

Today the SiteSearch maintainer has fixed some bugs in the plugin and I have also fixed some lines of code in the module. Next DEV will therefore work for sure. Minimum required SiteSearch version is v0.1.6 and can be downloaded under https://github.com/BeezyT/piwik-sitesearch

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.