Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Metrics.php3
-rw-r--r--core/Tracker/Action.php1
-rw-r--r--core/Tracker/Request.php1
-rw-r--r--plugins/Actions/Archiver.php2
-rw-r--r--plugins/Contents/Actions/ActionContent.php3
-rw-r--r--plugins/Contents/Archiver.php105
-rw-r--r--plugins/Contents/Columns/ContentInteraction.php56
-rw-r--r--plugins/Contents/Columns/ContentName.php3
-rw-r--r--plugins/Contents/DataArray.php36
-rw-r--r--plugins/Contents/lang/en.json1
10 files changed, 186 insertions, 25 deletions
diff --git a/core/Metrics.php b/core/Metrics.php
index 309ebc64d8..37685dd09a 100644
--- a/core/Metrics.php
+++ b/core/Metrics.php
@@ -140,7 +140,8 @@ class Metrics
Metrics::INDEX_EVENT_NB_HITS_WITH_VALUE => 'nb_events_with_value',
// Contents
- Metrics::INDEX_CONTENT_NB_IMPRESSIONS => 'nb_impressions'
+ Metrics::INDEX_CONTENT_NB_IMPRESSIONS => 'nb_impressions',
+ Metrics::INDEX_CONTENT_NB_INTERACTIONS => 'nb_interactions'
);
public static $mappingFromIdToNameGoal = array(
diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php
index 6d46987252..149e9b59b9 100644
--- a/core/Tracker/Action.php
+++ b/core/Tracker/Action.php
@@ -40,6 +40,7 @@ abstract class Action
const TYPE_CONTENT_PIECE = 13;
const TYPE_CONTENT_NAME = 14;
const TYPE_CONTENT_TARGET = 15;
+ const TYPE_CONTENT_INTERACTION = 16;
const DB_COLUMN_CUSTOM_FLOAT = 'custom_float';
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index 97469727c7..6a7f96b0b9 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -292,6 +292,7 @@ class Request
'c_p' => array('', 'string'),
'c_n' => array('', 'string'),
'c_t' => array('', 'string'),
+ 'c_i' => array('', 'string'),
);
if (!isset($supportedParams[$name])) {
diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php
index d5aafd6f6e..407019061c 100644
--- a/plugins/Actions/Archiver.php
+++ b/plugins/Actions/Archiver.php
@@ -123,7 +123,7 @@ class Archiver extends \Piwik\Plugin\Archiver
*/
public static function getWhereClauseActionIsNotEvent()
{
- return " AND log_link_visit_action.idaction_event_category IS NULL AND log_link_visit_action.idaction_content_piece IS NULL";
+ return " AND log_link_visit_action.idaction_event_category IS NULL AND log_link_visit_action.idaction_content_name IS NULL";
}
/**
diff --git a/plugins/Contents/Actions/ActionContent.php b/plugins/Contents/Actions/ActionContent.php
index e018bff3ec..de93127f99 100644
--- a/plugins/Contents/Actions/ActionContent.php
+++ b/plugins/Contents/Actions/ActionContent.php
@@ -29,8 +29,9 @@ class ActionContent extends Action
public static function shouldHandle(Request $request)
{
$name = $request->getParam('c_n');
+ $interaction = $request->getParam('c_i'); // if interaction is set we want it to be for instance an outlink, download, ...
- return !empty($name);
+ return !empty($name) && empty($interaction);
}
protected function getActionsToLookup()
diff --git a/plugins/Contents/Archiver.php b/plugins/Contents/Archiver.php
index 2af8c5ae63..c1175fc8b6 100644
--- a/plugins/Contents/Archiver.php
+++ b/plugins/Contents/Archiver.php
@@ -58,11 +58,12 @@ class Archiver extends \Piwik\Plugin\Archiver
public function aggregateDayReport()
{
- $this->aggregateDayContents();
+ $this->aggregateDayImpressions();
+ $this->aggregateDayInteractions();
$this->insertDayReports();
}
- private function aggregateDayContents()
+ private function aggregateDayImpressions()
{
$select = "
log_action_content_piece.name as contentPiece,
@@ -89,14 +90,15 @@ class Archiver extends \Piwik\Plugin\Archiver
array(
"table" => "log_action",
"tableAlias" => "log_action_content_name",
- "joinOn" => "log_link_visit_action.idaction_name = log_action_content_name.idaction"
+ "joinOn" => "log_link_visit_action.idaction_content_name = log_action_content_name.idaction"
)
);
$where = "log_link_visit_action.server_time >= ?
AND log_link_visit_action.server_time <= ?
AND log_link_visit_action.idsite = ?
- AND log_link_visit_action.idaction_content_piece IS NOT NULL";
+ AND log_link_visit_action.idaction_content_name IS NOT NULL
+ AND log_link_visit_action.idaction_content_interaction IS NULL";
$groupBy = "log_action_content_piece.idaction,
log_action_content_target.idaction,
@@ -114,7 +116,68 @@ class Archiver extends \Piwik\Plugin\Archiver
$rankingQuery->addColumn(array(Metrics::INDEX_CONTENT_NB_IMPRESSIONS, Metrics::INDEX_NB_VISITS), 'sum');
}
- $this->archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, $rankingQuery);
+ $resultSet = $this->archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, $rankingQuery);
+
+ while ($row = $resultSet->fetch()) {
+ $this->aggregateImpressionRow($row);
+ }
+ }
+
+ private function aggregateDayInteractions()
+ {
+ $select = "
+ log_action_content_name.name as contentName,
+ log_action_content_interaction.name as contentInteraction,
+ log_action_content_piece.name as contentPiece,
+
+ count(*) as `" . Metrics::INDEX_CONTENT_NB_INTERACTIONS . "`
+ ";
+
+ $from = array(
+ "log_link_visit_action",
+ array(
+ "table" => "log_action",
+ "tableAlias" => "log_action_content_piece",
+ "joinOn" => "log_link_visit_action.idaction_content_piece = log_action_content_piece.idaction"
+ ),
+ array(
+ "table" => "log_action",
+ "tableAlias" => "log_action_content_interaction",
+ "joinOn" => "log_link_visit_action.idaction_content_interaction = log_action_content_interaction.idaction"
+ ),
+ array(
+ "table" => "log_action",
+ "tableAlias" => "log_action_content_name",
+ "joinOn" => "log_link_visit_action.idaction_content_name = log_action_content_name.idaction"
+ )
+ );
+
+ $where = "log_link_visit_action.server_time >= ?
+ AND log_link_visit_action.server_time <= ?
+ AND log_link_visit_action.idsite = ?
+ AND log_link_visit_action.idaction_content_name IS NOT NULL
+ AND log_link_visit_action.idaction_content_interaction IS NOT NULL";
+
+ $groupBy = "log_action_content_piece.idaction,
+ log_action_content_interaction.idaction,
+ log_action_content_name.idaction";
+
+ $orderBy = "`" . Metrics::INDEX_CONTENT_NB_INTERACTIONS . "` DESC";
+
+ $rankingQueryLimit = ArchivingHelper::getRankingQueryLimit();
+ $rankingQuery = null;
+ if ($rankingQueryLimit > 0) {
+ $rankingQuery = new RankingQuery($rankingQueryLimit);
+ $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW);
+ $rankingQuery->addLabelColumn(array('contentPiece', 'contentInteraction', 'contentName'));
+ $rankingQuery->addColumn(array(Metrics::INDEX_CONTENT_NB_INTERACTIONS), 'sum');
+ }
+
+ $resultSet = $this->archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, $rankingQuery);
+
+ while ($row = $resultSet->fetch()) {
+ $this->aggregateInteractionRow($row);
+ }
}
private function archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, RankingQuery $rankingQuery)
@@ -134,9 +197,7 @@ class Archiver extends \Piwik\Plugin\Archiver
return;
}
- while ($row = $resultSet->fetch()) {
- $this->aggregateContentRow($row);
- }
+ return $resultSet;
}
/**
@@ -179,7 +240,7 @@ class Archiver extends \Piwik\Plugin\Archiver
return $this->arrays[$name];
}
- private function aggregateContentRow($row)
+ private function aggregateImpressionRow($row)
{
foreach ($this->getRecordToDimensions() as $record => $dimensions) {
$dataArray = $this->getDataArray($record);
@@ -187,7 +248,7 @@ class Archiver extends \Piwik\Plugin\Archiver
$mainDimension = $dimensions[0];
$mainLabel = $row[$mainDimension];
- $dataArray->sumMetricsContents($mainLabel, $row);
+ $dataArray->sumMetricsImpressions($mainLabel, $row);
$this->rememberMetadataForRow($row, $mainLabel, $mainDimension);
$subDimension = $dimensions[1];
@@ -197,7 +258,28 @@ class Archiver extends \Piwik\Plugin\Archiver
continue;
}
- $dataArray->sumMetricsContentsPivot($mainLabel, $subLabel, $row);
+ $dataArray->sumMetricsContentsImpressionPivot($mainLabel, $subLabel, $row);
+ }
+ }
+
+ private function aggregateInteractionRow($row)
+ {
+ foreach ($this->getRecordToDimensions() as $record => $dimensions) {
+ $dataArray = $this->getDataArray($record);
+
+ $mainDimension = $dimensions[0];
+ $mainLabel = $row[$mainDimension];
+
+ $dataArray->sumMetricsInteractions($mainLabel, $row);
+
+ $subDimension = $dimensions[1];
+ $subLabel = $row[$subDimension];
+
+ if (empty($subLabel)) {
+ continue;
+ }
+
+ $dataArray->sumMetricsContentsInteractionPivot($mainLabel, $subLabel, $row);
}
}
@@ -216,6 +298,7 @@ class Archiver extends \Piwik\Plugin\Archiver
$target = Archiver::CONTENT_TARGET_NOT_SET;
}
+ // there can be many different targets
$this->metadata[$mainLabel]['contentTarget'] = $target;
}
diff --git a/plugins/Contents/Columns/ContentInteraction.php b/plugins/Contents/Columns/ContentInteraction.php
new file mode 100644
index 0000000000..c5e49fd0e7
--- /dev/null
+++ b/plugins/Contents/Columns/ContentInteraction.php
@@ -0,0 +1,56 @@
+<?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\Contents\Columns;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Dimension\ActionDimension;
+use Piwik\Plugins\Actions\Segment;
+use Piwik\Tracker\Action;
+use Piwik\Tracker\Request;
+
+class ContentInteraction extends ActionDimension
+{
+ protected $columnName = 'idaction_content_interaction';
+ protected $columnType = 'INTEGER(10) UNSIGNED DEFAULT NULL';
+
+ protected function configureSegments()
+ {
+ $segment = new Segment();
+ $segment->setSegment('contentInteraction');
+ $segment->setName('Contents_Interaction');
+ $this->addSegment($segment);
+ }
+
+ public function getName()
+ {
+ return Piwik::translate('Contents_Interaction');
+ }
+
+ public function getActionId()
+ {
+ return Action::TYPE_CONTENT_INTERACTION;
+ }
+
+ public function onLookupAction(Request $request, Action $action)
+ {
+ $interaction = $request->getParam('c_i');
+
+ if (empty($interaction)) {
+ return false;
+ }
+
+ $interaction = trim($interaction);
+
+ if (strlen($interaction) > 0) {
+ return $interaction;
+ }
+
+ return false;
+ }
+} \ No newline at end of file
diff --git a/plugins/Contents/Columns/ContentName.php b/plugins/Contents/Columns/ContentName.php
index 21af924e4b..a33fdd0b29 100644
--- a/plugins/Contents/Columns/ContentName.php
+++ b/plugins/Contents/Columns/ContentName.php
@@ -17,7 +17,8 @@ use Piwik\Tracker\Request;
class ContentName extends ActionDimension
{
- protected $columnName = 'idaction_name';
+ protected $columnName = 'idaction_content_name';
+ protected $columnType = 'INTEGER(10) UNSIGNED DEFAULT NULL';
protected function configureSegments()
{
diff --git a/plugins/Contents/DataArray.php b/plugins/Contents/DataArray.php
index f83f06f624..98e7b0543c 100644
--- a/plugins/Contents/DataArray.php
+++ b/plugins/Contents/DataArray.php
@@ -19,12 +19,20 @@ use Piwik\Metrics;
class DataArray extends \Piwik\DataArray
{
- public function sumMetricsContents($label, $row)
+ public function sumMetricsImpressions($label, $row)
{
if (!isset($this->data[$label])) {
$this->data[$label] = self::makeEmptyContentsRow();
}
- $this->doSumContentsMetrics($row, $this->data[$label], $onlyMetricsAvailableInActionsTable = true);
+ $this->doSumContentsImpressionMetrics($row, $this->data[$label]);
+ }
+
+ public function sumMetricsInteractions($label, $row)
+ {
+ if (!isset($this->data[$label])) {
+ return; // do igonre interactions that do not have an impression
+ }
+ $this->doSumContentsInteractionMetrics($row, $this->data[$label]);
}
protected static function makeEmptyContentsRow()
@@ -37,24 +45,32 @@ class DataArray extends \Piwik\DataArray
);
}
- /**
- * @param array $newRowToAdd
- * @param array $oldRowToUpdate
- * @return void
- */
- protected function doSumContentsMetrics($newRowToAdd, &$oldRowToUpdate)
+ protected function doSumContentsImpressionMetrics($newRowToAdd, &$oldRowToUpdate)
{
$oldRowToUpdate[Metrics::INDEX_NB_VISITS] += $newRowToAdd[Metrics::INDEX_NB_VISITS];
$oldRowToUpdate[Metrics::INDEX_NB_UNIQ_VISITORS] += $newRowToAdd[Metrics::INDEX_NB_UNIQ_VISITORS];
$oldRowToUpdate[Metrics::INDEX_CONTENT_NB_IMPRESSIONS] += $newRowToAdd[Metrics::INDEX_CONTENT_NB_IMPRESSIONS];
}
- public function sumMetricsContentsPivot($parentLabel, $label, $row)
+ protected function doSumContentsInteractionMetrics($newRowToAdd, &$oldRowToUpdate)
+ {
+ $oldRowToUpdate[Metrics::INDEX_CONTENT_NB_INTERACTIONS] += $newRowToAdd[Metrics::INDEX_CONTENT_NB_INTERACTIONS];
+ }
+
+ public function sumMetricsContentsImpressionPivot($parentLabel, $label, $row)
{
if (!isset($this->dataTwoLevels[$parentLabel][$label])) {
$this->dataTwoLevels[$parentLabel][$label] = $this->makeEmptyContentsRow();
}
- $this->doSumContentsMetrics($row, $this->dataTwoLevels[$parentLabel][$label]);
+ $this->doSumContentsImpressionMetrics($row, $this->dataTwoLevels[$parentLabel][$label]);
+ }
+
+ public function sumMetricsContentsInteractionPivot($parentLabel, $label, $row)
+ {
+ if (!isset($this->dataTwoLevels[$parentLabel][$label])) {
+ return; // do igonre interactions that do not have an impression
+ }
+ $this->doSumContentsInteractionMetrics($row, $this->dataTwoLevels[$parentLabel][$label]);
}
}
diff --git a/plugins/Contents/lang/en.json b/plugins/Contents/lang/en.json
index 37acf673d4..87b13eec1c 100644
--- a/plugins/Contents/lang/en.json
+++ b/plugins/Contents/lang/en.json
@@ -2,6 +2,7 @@
"Contents":{
"Impressions":"Impressions",
"Interactions":"Interactions",
+ "Interaction":"Interaction",
"InteractionRate":"Interaction Rate",
"ContentName":"Content Name",
"ContentPiece":"Content Piece",