PDF rausgenommen
This commit is contained in:
81
msd2/tracking/piwik/plugins/Actions/Columns/ActionType.php
Normal file
81
msd2/tracking/piwik/plugins/Actions/Columns/ActionType.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\DimensionMetricFactory;
|
||||
use Piwik\Columns\MetricsList;
|
||||
use Piwik\Development;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* This example dimension only defines a name and does not track any data. It's supposed to be only used in reports.
|
||||
*
|
||||
* See {@link http://developer.piwik.org/api-reference/Piwik/Columns\Dimension} for more information.
|
||||
*/
|
||||
class ActionType extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'type';
|
||||
protected $dbTableName = 'log_action';
|
||||
protected $segmentName = 'actionType';
|
||||
protected $type = self::TYPE_ENUM;
|
||||
protected $nameSingular = 'Actions_ActionType';
|
||||
protected $namePlural = 'Actions_ActionTypes';
|
||||
protected $category = 'General_Actions';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->acceptValues = 'A type of action, such as: pageviews, contents, sitesearches, events, outlinks, downloads';
|
||||
}
|
||||
|
||||
public function getEnumColumnValues()
|
||||
{
|
||||
$availableTypes = [];
|
||||
/**
|
||||
* Triggered to determine the available action types
|
||||
*
|
||||
* Plugin can use this event to add their own action types, so they are available in segmentation
|
||||
* The array maps internal ids to readable action type names used in visitor details
|
||||
*
|
||||
* **Example**
|
||||
*
|
||||
* public function addActionTypes(&$availableTypes)
|
||||
* {
|
||||
* $availableTypes[] = array(
|
||||
* 'id' => 76,
|
||||
* 'name' => 'media_play'
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* @param array $availableTypes
|
||||
*/
|
||||
Piwik::postEvent('Actions.addActionTypes', [&$availableTypes]);
|
||||
|
||||
$types = [];
|
||||
|
||||
foreach ($availableTypes as $type) {
|
||||
if (empty($type['id']) || empty($type['name'])) {
|
||||
throw new Exception("Invalid action added with event `Actions.addActionTypes`: " . var_export($type, true));
|
||||
}
|
||||
if (Development::isEnabled() && array_key_exists($type['id'], $types)) {
|
||||
throw new Exception(sprintf("Action '%s' with id %s couldn't be added, as '%s' was already added for this id", $type['name'], $type['id'], $types[$type['id']]));
|
||||
}
|
||||
$types[$type['id']] = $type['name'];
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
|
||||
{
|
||||
// do not genereate any metric for this
|
||||
}
|
||||
|
||||
}
|
29
msd2/tracking/piwik/plugins/Actions/Columns/ActionUrl.php
Normal file
29
msd2/tracking/piwik/plugins/Actions/Columns/ActionUrl.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Plugins\Actions\Segment;
|
||||
|
||||
class ActionUrl extends ActionDimension
|
||||
{
|
||||
protected $nameSingular = 'Actions_ColumnActionURL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('actionUrl');
|
||||
$segment->setName('Actions_ColumnActionURL');
|
||||
$segment->setUnionOfSegments(array('pageUrl', 'downloadUrl', 'outlinkUrl', 'eventUrl'));
|
||||
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
}
|
35
msd2/tracking/piwik/plugins/Actions/Columns/ClickedUrl.php
Normal file
35
msd2/tracking/piwik/plugins/Actions/Columns/ClickedUrl.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class ClickedUrl extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'idaction_url';
|
||||
protected $segmentName = 'outlinkUrl';
|
||||
protected $nameSingular = 'Actions_ColumnClickedURL';
|
||||
protected $namePlural = 'Actions_ColumnClickedURLs';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
protected $type = self::TYPE_URL;
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_OUTLINK);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class DestinationPage extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'General_ColumnDestinationPage';
|
||||
}
|
35
msd2/tracking/piwik/plugins/Actions/Columns/DownloadUrl.php
Normal file
35
msd2/tracking/piwik/plugins/Actions/Columns/DownloadUrl.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class DownloadUrl extends ActionDimension
|
||||
{
|
||||
protected $segmentName = 'downloadUrl';
|
||||
protected $nameSingular = 'Actions_ColumnDownloadURL';
|
||||
protected $namePlural = 'Actions_ColumnDownloadURLs';
|
||||
protected $columnName = 'idaction_url';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
protected $type = self::TYPE_URL;
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_DOWNLOAD);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class EntryPageTitle extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_entry_idaction_name';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED NULL';
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $segmentName = 'entryPageTitle';
|
||||
protected $nameSingular = 'Actions_ColumnEntryPageTitle';
|
||||
protected $namePlural = 'Actions_WidgetEntryPageTitles';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$idActionName = false;
|
||||
|
||||
if (!empty($action)) {
|
||||
$idActionName = $action->getIdActionNameForEntryAndExitIds();
|
||||
}
|
||||
|
||||
return (int) $idActionName;
|
||||
}
|
||||
}
|
80
msd2/tracking/piwik/plugins/Actions/Columns/EntryPageUrl.php
Normal file
80
msd2/tracking/piwik/plugins/Actions/Columns/EntryPageUrl.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class EntryPageUrl extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_entry_idaction_url';
|
||||
protected $columnType = 'INTEGER(11) UNSIGNED NULL DEFAULT NULL';
|
||||
protected $segmentName = 'entryPageUrl';
|
||||
protected $nameSingular = 'Actions_ColumnEntryPageURL';
|
||||
protected $namePlural = 'Actions_ColumnEntryPageURLs';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
protected $type = self::TYPE_URL;
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$idActionUrl = false;
|
||||
|
||||
if (!empty($action)) {
|
||||
$idActionUrl = $action->getIdActionUrlForEntryAndExitIds();
|
||||
}
|
||||
|
||||
if($idActionUrl === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $idActionUrl;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$idAction = $visitor->getVisitorColumn('visit_entry_idaction_url');
|
||||
|
||||
if (is_null($idAction) && !empty($action)) {
|
||||
$idAction = $action->getIdActionUrlForEntryAndExitIds();
|
||||
if (!empty($idAction)) {
|
||||
return $idAction;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class ExitPageTitle extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_exit_idaction_name';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED NULL';
|
||||
protected $segmentName = 'exitPageTitle';
|
||||
protected $nameSingular = 'Actions_ColumnExitPageTitle';
|
||||
protected $namePlural = 'Actions_WidgetExitPageTitles';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
protected $type = self::TYPE_TEXT;
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int|bool
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$idActionName = false;
|
||||
|
||||
if (!empty($action)) {
|
||||
$idActionName = $action->getIdActionNameForEntryAndExitIds();
|
||||
}
|
||||
|
||||
return (int) $idActionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int|bool
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if (empty($action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $action->getIdActionNameForEntryAndExitIds();
|
||||
}
|
||||
}
|
84
msd2/tracking/piwik/plugins/Actions/Columns/ExitPageUrl.php
Normal file
84
msd2/tracking/piwik/plugins/Actions/Columns/ExitPageUrl.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\DimensionMetricFactory;
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join;
|
||||
use Piwik\Columns\MetricsList;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class ExitPageUrl extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_exit_idaction_url';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED NULL DEFAULT 0';
|
||||
protected $type = self::TYPE_URL;
|
||||
protected $segmentName = 'exitPageUrl';
|
||||
protected $nameSingular = 'Actions_ColumnExitPageURL';
|
||||
protected $namePlural = 'Actions_ColumnExitPageURLs';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
|
||||
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
|
||||
{
|
||||
parent::configureMetrics($metricsList, $dimensionMetricFactory);
|
||||
}
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new Join\ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int|bool
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$idActionUrl = false;
|
||||
|
||||
if (!empty($action)) {
|
||||
$idActionUrl = $action->getIdActionUrlForEntryAndExitIds();
|
||||
}
|
||||
|
||||
return (int) $idActionUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if (empty($action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$id = $action->getIdActionUrlForEntryAndExitIds();
|
||||
|
||||
if (!empty($id)) {
|
||||
$id = (int) $id;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
44
msd2/tracking/piwik/plugins/Actions/Columns/IdPageview.php
Normal file
44
msd2/tracking/piwik/plugins/Actions/Columns/IdPageview.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\DimensionMetricFactory;
|
||||
use Piwik\Columns\MetricsList;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
|
||||
class IdPageview extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'idpageview';
|
||||
protected $columnType = 'CHAR(6) NULL DEFAULT NULL';
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'Actions_ColumnIdPageview';
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action $action
|
||||
*
|
||||
* @return mixed|false
|
||||
* @api
|
||||
*/
|
||||
public function onNewAction(Request $request, Visitor $visitor, Action $action)
|
||||
{
|
||||
return substr($request->getParam('pv_id'), 0, 6);
|
||||
}
|
||||
|
||||
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
|
||||
{
|
||||
// metrics for idpageview do not really make any sense
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Plugins\Events\Actions\ActionEvent;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
|
||||
class InteractionPosition extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'interaction_position';
|
||||
protected $columnType = 'SMALLINT UNSIGNED DEFAULT NULL';
|
||||
protected $nameSingular = 'Actions_ColumnInteractionPosition';
|
||||
protected $type = self::TYPE_NUMBER;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action $action
|
||||
*
|
||||
* @return mixed|false
|
||||
*/
|
||||
public function onNewAction(Request $request, Visitor $visitor, Action $action)
|
||||
{
|
||||
$shouldCount = VisitTotalInteractions::shouldCountInteraction($action);
|
||||
|
||||
if ($shouldCount && $visitor->isNewVisit()) {
|
||||
return 1;
|
||||
} else if ($shouldCount) {
|
||||
return VisitTotalInteractions::getNextInteractionPosition($request);
|
||||
}
|
||||
|
||||
// we re-use same interaction position as last page view eg for events etc.
|
||||
$position = VisitTotalInteractions::getCurrentInteractionPosition($request);
|
||||
if ($position >= 1) {
|
||||
return $position;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
18
msd2/tracking/piwik/plugins/Actions/Columns/Keyword.php
Normal file
18
msd2/tracking/piwik/plugins/Actions/Columns/Keyword.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class Keyword extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'General_ColumnKeyword';
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class KeywordwithNoSearchResult extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'Actions_ColumnNoResultKeyword';
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable;
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The average amount of time it takes to generate a page. Calculated as
|
||||
*
|
||||
* sum_time_generation / nb_hits_with_time_generation
|
||||
*
|
||||
* The above metrics are calculated during archiving. This metric is calculated before
|
||||
* serving a report.
|
||||
*/
|
||||
class AveragePageGenerationTime extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'avg_time_generation';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnAverageGenerationTime');
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('sum_time_generation', 'nb_hits_with_time_generation');
|
||||
}
|
||||
|
||||
public function getTemporaryMetrics()
|
||||
{
|
||||
return array('sum_time_generation');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$sumGenerationTime = $this->getMetric($row, 'sum_time_generation');
|
||||
$hitsWithTimeGeneration = $this->getMetric($row, 'nb_hits_with_time_generation');
|
||||
|
||||
return Piwik::getQuotientSafe($sumGenerationTime, $hitsWithTimeGeneration, $precision = 3);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
if ($formatter instanceof Formatter\Html
|
||||
&& !$value
|
||||
) {
|
||||
return '-';
|
||||
} else {
|
||||
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeCompute($report, DataTable $table)
|
||||
{
|
||||
$hasTimeGeneration = array_sum($this->getMetricValues($table, 'sum_time_generation')) > 0;
|
||||
|
||||
if (!$hasTimeGeneration
|
||||
&& $table->getRowsCount() != 0
|
||||
&& !$this->hasAverageTimeGeneration($table)
|
||||
) {
|
||||
// No generation time: remove it from the API output and add it to empty_columns metadata, so that
|
||||
// the columns can also be removed from the view
|
||||
$table->filter('ColumnDelete', array(array(
|
||||
Metrics::INDEX_PAGE_SUM_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_MIN_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_MAX_TIME_GENERATION,
|
||||
'sum_time_generation',
|
||||
'nb_hits_with_time_generation',
|
||||
'min_time_generation',
|
||||
'max_time_generation'
|
||||
)));
|
||||
|
||||
if ($table instanceof DataTable) {
|
||||
$emptyColumns = $table->getMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME);
|
||||
if (!is_array($emptyColumns)) {
|
||||
$emptyColumns = array();
|
||||
}
|
||||
$emptyColumns[] = 'sum_time_generation';
|
||||
$emptyColumns[] = 'avg_time_generation';
|
||||
$emptyColumns[] = 'min_time_generation';
|
||||
$emptyColumns[] = 'max_time_generation';
|
||||
$table->setMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME, $emptyColumns);
|
||||
}
|
||||
}
|
||||
|
||||
return $hasTimeGeneration;
|
||||
}
|
||||
|
||||
private function hasAverageTimeGeneration(DataTable $table)
|
||||
{
|
||||
return $table->getFirstRow()->getColumn('avg_time_generation') !== false;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The average amount of time spent on a page. Calculated as:
|
||||
*
|
||||
* sum_time_spent / nb_visits
|
||||
*
|
||||
* sum_time_spent and nb_visits are calculated by Archiver classes.
|
||||
*/
|
||||
class AverageTimeOnPage extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'avg_time_on_page';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnAverageTimeOnPage');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$sumTimeSpent = $this->getMetric($row, 'sum_time_spent');
|
||||
$visits = $this->getMetric($row, 'nb_hits');
|
||||
|
||||
return Piwik::getQuotientSafe($sumTimeSpent, $visits, $precision = 0);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyTimeFromSeconds($value, $timeAsSentence = false);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('sum_time_spent', 'nb_hits');
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The bounce rate for individual pages. Calculated as:
|
||||
*
|
||||
* entry_bounce_count (single page visits on this page) / entry_nb_visits (all visits that started on this page)
|
||||
*
|
||||
* entry_bounce_count & entry_nb_visits are calculated by the Actions archiver.
|
||||
*/
|
||||
class BounceRate extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'bounce_rate';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnBounceRate');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$entryBounceCount = $this->getMetric($row, 'entry_bounce_count');
|
||||
$entryVisits = $this->getMetric($row, 'entry_nb_visits');
|
||||
|
||||
return Piwik::getQuotientSafe($entryBounceCount, $entryVisits, $precision = 2);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyPercentFromQuotient($value);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('entry_bounce_count', 'entry_nb_visits');
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* Percent of visits that finished on this page. Calculated as:
|
||||
*
|
||||
* exit_nb_visits / nb_visits
|
||||
*
|
||||
* exit_nb_visits & nb_visits are calculated by the Actions archiver.
|
||||
*/
|
||||
class ExitRate extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'exit_rate';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnExitRate');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$exitVisits = $this->getMetric($row, 'exit_nb_visits');
|
||||
$visits = $this->getMetric($row, 'nb_visits');
|
||||
|
||||
return Piwik::getQuotientSafe($exitVisits, $visits, $precision = 2);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyPercentFromQuotient($value);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('exit_nb_visits', 'nb_visits');
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\DimensionMetricFactory;
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\MetricsList;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ArchivedMetric;
|
||||
use Piwik\Plugin\ComputedMetric;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class PageGenerationTime extends ActionDimension
|
||||
{
|
||||
protected $nameSingular = 'General_ColumnPageGenerationTime';
|
||||
protected $columnName = 'custom_float';
|
||||
protected $category = 'General_Actions';
|
||||
protected $type = self::TYPE_DURATION_MS;
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_URL);
|
||||
}
|
||||
|
||||
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
|
||||
{
|
||||
$metric1 = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
|
||||
$metricsList->addMetric($metric1);
|
||||
|
||||
$metric2 = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_MAX);
|
||||
$metricsList->addMetric($metric2);
|
||||
|
||||
$metric3 = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_COUNT_WITH_NUMERIC_VALUE);
|
||||
$metric3->setName('pageviews_with_generation_time');
|
||||
$metric3->setTranslatedName(Piwik::translate('General_ColumnViewsWithGenerationTime'));
|
||||
$metricsList->addMetric($metric3);
|
||||
|
||||
$metric = $dimensionMetricFactory->createComputedMetric($metric1->getName(), $metric3->getName(), ComputedMetric::AGGREGATION_AVG);
|
||||
$metric->setName('avg_page_generation_time');
|
||||
$metric->setTranslatedName(Piwik::translate('General_ColumnAverageGenerationTime'));
|
||||
$metricsList->addMetric($metric);
|
||||
}
|
||||
}
|
36
msd2/tracking/piwik/plugins/Actions/Columns/PageTitle.php
Normal file
36
msd2/tracking/piwik/plugins/Actions/Columns/PageTitle.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class PageTitle extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'idaction_name';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED';
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $segmentName = 'pageTitle';
|
||||
protected $nameSingular = 'Goals_PageTitle';
|
||||
protected $namePlural = 'Actions_WidgetPageTitles';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_TITLE);
|
||||
}
|
||||
}
|
39
msd2/tracking/piwik/plugins/Actions/Columns/PageUrl.php
Normal file
39
msd2/tracking/piwik/plugins/Actions/Columns/PageUrl.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class PageUrl extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'idaction_url';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED DEFAULT NULL';
|
||||
protected $segmentName = 'pageUrl';
|
||||
protected $nameSingular = 'Actions_ColumnPageURL';
|
||||
protected $namePlural = 'Actions_PageUrls';
|
||||
protected $type = self::TYPE_URL;
|
||||
protected $acceptValues = 'All these segments must be URL encoded, for example: http%3A%2F%2Fexample.com%2Fpath%2Fpage%3Fquery';
|
||||
protected $category = 'General_Actions';
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_PAGE_URL);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class SearchCategory extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'Actions_ColumnSearchCategory';
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class SearchDestinationPage extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'General_ColumnDestinationPage';
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Discriminator;
|
||||
use Piwik\Columns\Join\ActionNameJoin;
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class SearchKeyword extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'idaction_name';
|
||||
protected $segmentName = 'siteSearchKeyword';
|
||||
protected $nameSingular = 'Actions_SiteSearchKeyword';
|
||||
protected $namePlural = 'Actions_SiteSearchKeywords';
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment';
|
||||
|
||||
public function getDbColumnJoin()
|
||||
{
|
||||
return new ActionNameJoin();
|
||||
}
|
||||
|
||||
public function getDbDiscriminator()
|
||||
{
|
||||
return new Discriminator('log_action', 'type', Action::TYPE_SITE_SEARCH);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class SearchNoResultKeyword extends Dimension
|
||||
{
|
||||
protected $type = self::TYPE_TEXT;
|
||||
protected $nameSingular = 'Actions_ColumnNoResultKeyword';
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Plugin\Dimension\ActionDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class TimeSpentRefAction extends ActionDimension
|
||||
{
|
||||
protected $columnName = 'time_spent_ref_action';
|
||||
protected $columnType = 'INTEGER(10) UNSIGNED NULL';
|
||||
protected $type = self::TYPE_DURATION_S;
|
||||
|
||||
public function onNewAction(Request $request, Visitor $visitor, Action $action)
|
||||
{
|
||||
$timeSpent = $visitor->getVisitorColumn('time_spent_ref_action');
|
||||
|
||||
if (empty($timeSpent)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $timeSpent;
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Columns\MetricsList;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ArchivedMetric;
|
||||
use Piwik\Plugin\ComputedMetric;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Columns\DimensionMetricFactory;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class VisitTotalActions extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_total_actions';
|
||||
protected $columnType = 'INT(11) UNSIGNED NULL';
|
||||
protected $metricId = 'actions';
|
||||
protected $nameSingular = 'Actions_ActionsInVisit';
|
||||
protected $segmentName = 'actions';
|
||||
protected $type = self::TYPE_NUMBER;
|
||||
|
||||
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
|
||||
{
|
||||
$metric1 = $dimensionMetricFactory->createCustomMetric('bounce_count', Piwik::translate('General_ColumnBounces'), 'sum(case %s when 1 then 1 when 0 then 1 else 0 end)');
|
||||
$metric1->setDocumentation(Piwik::translate('General_ColumnBouncesDocumentation'));
|
||||
$metricsList->addMetric($metric1);
|
||||
|
||||
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
|
||||
$metricsList->addMetric($metric);
|
||||
|
||||
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_MAX);
|
||||
$metricsList->addMetric($metric);
|
||||
|
||||
$metric = $dimensionMetricFactory->createComputedMetric($metric1->getName(), 'nb_visits', ComputedMetric::AGGREGATION_RATE);
|
||||
$metric->setTranslatedName(Piwik::translate('General_ColumnBounceRate'));
|
||||
$metric->setName('bounce_rate');
|
||||
$metric->setDocumentation(Piwik::translate('General_ColumnBounceRateDocumentation'));
|
||||
$metricsList->addMetric($metric);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$actionType = false;
|
||||
if ($action) {
|
||||
$actionType = $action->getActionType();
|
||||
}
|
||||
|
||||
$actions = array(
|
||||
Action::TYPE_PAGE_URL,
|
||||
Action::TYPE_DOWNLOAD,
|
||||
Action::TYPE_OUTLINK,
|
||||
Action::TYPE_SITE_SEARCH,
|
||||
Action::TYPE_EVENT
|
||||
);
|
||||
|
||||
// if visit starts with something else (e.g. ecommerce order), don't record as an action
|
||||
if (in_array($actionType, $actions)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if (!$action) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$increment = 'visit_total_actions + 1';
|
||||
|
||||
$idActionUrl = $action->getIdActionUrlForEntryAndExitIds();
|
||||
|
||||
if ($idActionUrl !== false) {
|
||||
return $increment;
|
||||
}
|
||||
|
||||
$actionType = $action->getActionType();
|
||||
$types = array(Action::TYPE_SITE_SEARCH, Action::TYPE_EVENT, Action::TYPE_OUTLINK, Action::TYPE_DOWNLOAD);
|
||||
|
||||
if (in_array($actionType, $types)) {
|
||||
return $increment;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Plugins\CoreHome\Segment;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class VisitTotalInteractions extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_total_interactions';
|
||||
protected $columnType = 'SMALLINT UNSIGNED DEFAULT 0';
|
||||
protected $type = self::TYPE_NUMBER;
|
||||
protected $segmentName = 'interactions';
|
||||
protected $nameSingular = 'General_NbInteractions';
|
||||
protected $acceptValues = 'Any positive integer';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) {
|
||||
$positions = range(1,50);
|
||||
|
||||
return array_slice($positions, 0, $maxValuesToReturn);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if (self::shouldCountInteraction($action)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$request->setMetadata('Actions', $this->columnName, $visitor->getVisitorColumn($this->columnName));
|
||||
|
||||
if (self::shouldCountInteraction($action)) {
|
||||
return $this->columnName . ' + 1';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return int
|
||||
*/
|
||||
public static function getCurrentInteractionPosition($request)
|
||||
{
|
||||
$position = $request->getMetadata('Actions', 'visit_total_interactions');
|
||||
|
||||
return (int) $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return int
|
||||
*/
|
||||
public static function getNextInteractionPosition($request)
|
||||
{
|
||||
$position = self::getCurrentInteractionPosition($request);
|
||||
|
||||
$position = $position + 1;
|
||||
|
||||
// Remove this in Piwik 4
|
||||
return min($position, 32765);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Action|null $action
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldCountInteraction($action)
|
||||
{
|
||||
if (empty($action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$idActionUrl = $action->getIdActionUrlForEntryAndExitIds();
|
||||
|
||||
if ($idActionUrl !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$actionType = $action->getActionType();
|
||||
$types = array(Action::TYPE_SITE_SEARCH);
|
||||
|
||||
if (in_array($actionType, $types)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns;
|
||||
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class VisitTotalSearches extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_total_searches';
|
||||
protected $columnType = 'SMALLINT(5) UNSIGNED NULL';
|
||||
protected $segmentName = 'searches';
|
||||
protected $nameSingular = 'General_NbSearches';
|
||||
protected $acceptValues = 'To select all visits who used internal Site Search, use: &segment=searches>0';
|
||||
protected $type = self::TYPE_NUMBER;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if ($this->isSiteSearchAction($action)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return int
|
||||
*/
|
||||
public function onExistingVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
if ($this->isSiteSearchAction($action)) {
|
||||
return 'visit_total_searches + 1';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Action|null $action
|
||||
* @return bool
|
||||
*/
|
||||
private function isSiteSearchAction($action)
|
||||
{
|
||||
return ($action && $action->getActionType() == Action::TYPE_SITE_SEARCH);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user