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:
authorBeezyT <timo@ezdesign.de>2012-09-25 17:24:09 +0400
committerBeezyT <timo@ezdesign.de>2012-09-25 17:24:09 +0400
commitc653a35f7805e76e51c297257f5a5af0c3582acb (patch)
tree146239941856afadb7f056c090ccd4e1d8222dab /plugins/Transitions
parent71286e3e6067f3ad4144aa602453370fe1a6af9e (diff)
refs #3332 Transitions:
* if a url isn't found in the actions report, show the rest of the UI even though exits and bounces are not available (previously, there was an error message) * the number of pageviews is derived from the live queries - makes data more consistent * sanitize data taken from actions report using the live data * more robust second hash handling git-svn-id: http://dev.piwik.org/svn/trunk@7057 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/Transitions')
-rw-r--r--plugins/Transitions/API.php42
-rw-r--r--plugins/Transitions/Transitions.php50
-rw-r--r--plugins/Transitions/templates/transitions.js22
3 files changed, 79 insertions, 35 deletions
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php
index 8e3d0acff2..f876dd11ea 100644
--- a/plugins/Transitions/API.php
+++ b/plugins/Transitions/API.php
@@ -117,26 +117,13 @@ class Piwik_Transitions_API
throw new Exception("Actions.getPageUrls returned an error: ".$e->getMessage()."\n");
}
- if ($dataTable->getRowsCount() == 0)
+ if ($dataTable->getRowsCount() > 0 && ($row = $dataTable->getFirstRow()) !== false)
{
- throw new Exception('NoDataForUrl');
+ $report['pageMetrics'] = array(
+ 'exits' => intval($row->getColumn('exit_nb_visits')),
+ 'bounces' => intval($row->getColumn('entry_bounce_count'))
+ );
}
-
- $row = $dataTable->getFirstRow();
-
- if ($row !== false) {
- $report['pageMetrics'] = array(
- 'pageviews' => intval($row->getColumn('nb_hits')),
- 'exits' => intval($row->getColumn('exit_nb_visits')),
- 'bounces' => intval($row->getColumn('entry_bounce_count'))
- );
- } else {
- $report['pageMetrics'] = array(
- 'pageviews' => 0,
- 'exits' => 0,
- 'bounces' => 0
- );
- }
}
/**
@@ -162,7 +149,8 @@ class Piwik_Transitions_API
$data = $transitionsArchiving->queryInternalReferrers($idaction, $archiveProcessing, $limitBeforeGrouping);
$report['previousPages'] = &$data['previousPages'];
- $report['pageMetrics']['loops'] = intval($data['loops']);
+ $report['pageMetrics']['loops'] = $data['loops'];
+ $report['pageMetrics']['pageviews'] = $data['pageviews'];
$data = $transitionsArchiving->queryFollowingActions($idaction, $archiveProcessing, $limitBeforeGrouping);
foreach ($data as $tableName => $table) {
@@ -213,6 +201,22 @@ class Piwik_Transitions_API
'visits' => 0
);
}
+
+ // sanitize values taken from the actions report in addMainPageMetricsToReport().
+ // in some cases (e.g. URLs in DB with hash, actions report without hash), multiple
+ // idactions get mapped to one row in the actions report. in this case, the numbers
+ // are higher. we compensate for that here.
+ if (isset($report['pageMetrics']['exits'])) {
+ $report['pageMetrics']['exitsBefore'] = $report['pageMetrics']['exits'];
+
+ $followingActions = $transitionsArchiving->getTotalTransitionsToFollowingActions();
+ $report['pageMetrics']['exits'] = min($report['pageMetrics']['exits'],
+ $report['pageMetrics']['pageviews'] - $followingActions);
+ $report['pageMetrics']['bounces'] = min($report['pageMetrics']['bounces'],
+ $report['pageMetrics']['exits']);
+ $report['pageMetrics']['bounces'] = min($report['pageMetrics']['bounces'],
+ $report['pageMetrics']['entries']);
+ }
}
private function getReferrerLabel($referrerId) {
diff --git a/plugins/Transitions/Transitions.php b/plugins/Transitions/Transitions.php
index 94c02d84b7..a64c443588 100644
--- a/plugins/Transitions/Transitions.php
+++ b/plugins/Transitions/Transitions.php
@@ -140,14 +140,15 @@ class Piwik_Transitions extends Piwik_Plugin
$rankingQuery = new Piwik_RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping);
$rankingQuery->addLabelColumn(array('name', 'url_prefix'));
$rankingQuery->setColumnToMarkExcludedRows('is_self');
+ $rankingQuery->partitionResultIntoMultipleGroups('is_page', array(0, 1));
$addSelect = '
log_action.name, log_action.url_prefix,
- CASE WHEN log_link_visit_action.idaction_url_ref = '.intval($idaction).' THEN 1 ELSE 0 END AS is_self';
+ CASE WHEN log_link_visit_action.idaction_url_ref = '.intval($idaction).' THEN 1 ELSE 0 END AS is_self,
+ CASE WHEN log_action.type = '.Piwik_Tracker_Action::TYPE_ACTION_URL.' THEN 1 ELSE 0 END AS is_page';
$where = '
- log_link_visit_action.idaction_url = '.intval($idaction).' AND
- log_action.type = '.Piwik_Tracker_Action::TYPE_ACTION_URL;
+ log_link_visit_action.idaction_url = '.intval($idaction);
$orderBy = '`'.Piwik_Archive::INDEX_NB_ACTIONS.'` DESC';
@@ -155,24 +156,38 @@ class Piwik_Transitions extends Piwik_Plugin
$data = $archiveProcessing->queryActionsByDimension(array($dimension), $where, $metrics, $orderBy,
$rankingQuery, $dimension, $addSelect);
+ $nbPageviews = 0;
$previousPagesDataTable = new Piwik_DataTable;
- foreach ($data['result'] as &$page)
- {
- $previousPagesDataTable->addRow(new Piwik_DataTable_Row(array(
- Piwik_DataTable_Row::COLUMNS => array(
- 'label' => Piwik_Tracker_Action::reconstructNormalizedUrl($page['name'], $page['url_prefix']),
- Piwik_Archive::INDEX_NB_ACTIONS => intval($page[Piwik_Archive::INDEX_NB_ACTIONS])
- )
- )));
+ if (isset($data['result'][1])) {
+ foreach ($data['result'][1] as &$page)
+ {
+ $nbActions = intval($page[Piwik_Archive::INDEX_NB_ACTIONS]);
+ $previousPagesDataTable->addRow(new Piwik_DataTable_Row(array(
+ Piwik_DataTable_Row::COLUMNS => array(
+ 'label' => Piwik_Tracker_Action::reconstructNormalizedUrl($page['name'], $page['url_prefix']),
+ Piwik_Archive::INDEX_NB_ACTIONS => $nbActions
+ )
+ )));
+ $nbPageviews += $nbActions;
+ }
+ }
+
+ if (isset($data['result'][0])) {
+ foreach ($data['result'][0] as &$referrer)
+ {
+ $nbPageviews += intval($referrer[Piwik_Archive::INDEX_NB_ACTIONS]);
+ }
}
$loops = 0;
if (count($data['excludedFromLimit']))
{
$loops = intval($data['excludedFromLimit'][0][Piwik_Archive::INDEX_NB_ACTIONS]);
+ $nbPageviews += $loops;
}
return array(
+ 'pageviews' => $nbPageviews,
'previousPages' => $previousPagesDataTable,
'loops' => $loops
);
@@ -212,6 +227,7 @@ class Piwik_Transitions extends Piwik_Plugin
$data = $archiveProcessing->queryActionsByDimension(array($dimension), $where, $metrics, $orderBy,
$rankingQuery, $dimension, $addSelect);
+ $this->totalTransitionsToFollowingActions = 0;
$dataTables = array();
foreach ($types as $type => $recordName)
{
@@ -220,14 +236,16 @@ class Piwik_Transitions extends Piwik_Plugin
{
foreach ($data[$type] as &$record)
{
+ $actions = intval($record[Piwik_Archive::INDEX_NB_ACTIONS]);
$dataTable->addRow(new Piwik_DataTable_Row(array(
Piwik_DataTable_Row::COLUMNS => array(
'label' => $type == Piwik_Tracker_Action::TYPE_ACTION_URL ?
Piwik_Tracker_Action::reconstructNormalizedUrl($record['name'], $record['url_prefix']) :
$record['name'],
- Piwik_Archive::INDEX_NB_ACTIONS => intval($record[Piwik_Archive::INDEX_NB_ACTIONS])
+ Piwik_Archive::INDEX_NB_ACTIONS => $actions
)
)));
+ $this->totalTransitionsToFollowingActions += $actions;
}
}
$dataTables[$recordName] = $dataTable;
@@ -236,4 +254,12 @@ class Piwik_Transitions extends Piwik_Plugin
return $dataTables;
}
+ /**
+ * Get the sum of all transitions to following actions (pages, outlinks, downloads).
+ * Only works if queryFollowingActions() has been used directly before.
+ */
+ public function getTotalTransitionsToFollowingActions() {
+ return $this->totalTransitionsToFollowingActions;
+ }
+
} \ No newline at end of file
diff --git a/plugins/Transitions/templates/transitions.js b/plugins/Transitions/templates/transitions.js
index bd41ef0a48..5b88a7f9b9 100644
--- a/plugins/Transitions/templates/transitions.js
+++ b/plugins/Transitions/templates/transitions.js
@@ -189,7 +189,15 @@ Piwik_Transitions.prototype.renderCenterBox = function() {
var el = box.find('.Transitions_' + cssClass);
Piwik_Transitions_Util.replacePlaceholderInHtml(el, self.model[modelProperty]);
- if (self.model[modelProperty] == 0) {
+ if (self.model[modelProperty] === null) {
+ // bounces and exits are null if the url was not found in the actions report.
+ // this happens when the report has been truncated.
+ if (modelProperty == 'exits') {
+ el.parent().hide();
+ } else {
+ el.hide();
+ }
+ } else if (self.model[modelProperty] == 0) {
el.addClass('Transitions_Value0');
} else {
self.addTooltipShowingPercentageOfAllPageviews(el, modelProperty);
@@ -1021,10 +1029,16 @@ Piwik_Transitions_Model.prototype.loadData = function(link, callback) {
// load page metrics
self.pageviews = report.pageMetrics.pageviews;
- self.exits = report.pageMetrics.exits;
- self.bounces = report.pageMetrics.bounces;
self.loops = report.pageMetrics.loops;
+ if (typeof report.pageMetrics.exits == 'undefined') {
+ self.exits = null;
+ self.bounces = null;
+ } else {
+ self.exits = report.pageMetrics.exits;
+ self.bounces = report.pageMetrics.bounces;
+ }
+
// load referrers: split direct entries and others
for (var i = 0; i < report.referrers.length; i++) {
var referrer = report.referrers[i];
@@ -1049,7 +1063,7 @@ Piwik_Transitions_Model.prototype.loadData = function(link, callback) {
self.loadAndSumReport(report, 'followingPages');
self.loadAndSumReport(report, 'downloads');
self.loadAndSumReport(report, 'outlinks');
-
+
callback();
});
};