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:
authorThomas Steur <tsteur@users.noreply.github.com>2017-10-03 23:22:01 +0300
committerGitHub <noreply@github.com>2017-10-03 23:22:01 +0300
commit9af4e95aa976f3a6533e95b776b5298f73e5f916 (patch)
treed612cd4d32019e9e52ce1398b8bf214ec06a8e0f /plugins/Goals/Goals.php
parent359c3ec875b554c7b71a933b26d18cdde0bb8f4e (diff)
Better segment editor and fixes (#12040)
* column tweak * fix install * more tweaks * rename column to dimension * various fixes * added new control expandable select * starting to refactor segment selector * make segment editor work again * use translation keys * defined some metrics * set types * simplify * simplify * fix join generator * add possibility to use custom join table names when using query builder and it uses an inner query * fix bug in query selector when selecting same field name from different tables twice * more metadata * more tweaks * improve selector * add possibility to use custom entity names * also processed archived metrics * generate sql filter, suggested values callback, and accept values automatically for columns with enums * several tweaks * focus search field when opening it * various tweaks * added missing method * format and fix more metadata * more fixes * better definition * define custom filter * fix definition * fix various tests * fix more tests * fix bug in logquery builder * fix referrerurl segment was missing * fix some tests * fix more tests * add group * refactor for better definition * fix a bug in log query builder when similar columns are used in archiver * add goal metrics * various fixes * make datatable row more flexible * various fixes and visualization enhancements * simply segment editor and make it smaller * remove trailing comma * various fixes and added new dimension * fix formatting of returning customer * added missing primary key * fixes * various fixes and improvements * make sure to update segment definition when selecting a value from auto complete list * various fixes and more metrics * more metrics * more dimensions and fixes * fix some tests * fix some integration tests * update submodule * fix some system tests * fix ui tests * trigger new test run * fix more ui tests * fix system tests * update submodule * fix categories * sort segments by category for more consistency * add custom variables * some translations and fixes * add minute segment * more segments * added plurals * added some docs * fix test * fix tests * fix tests * added suggested values * fix some tests * various fixes * fix more tests * allow to select segments on any site * make sure to include file * added doc block * fix some system tests * fix most system tests * fix ui test * fix system test * adjust examples * added more tests and docs * no metrics for these dimensions * added developer changelog and made some classes public api * some fixes for entity names * add possibility to set format metrics in test * more consistency in defining the name * get idsites only if provided * fix integration tests * added another segment for visit start hour and visit start minute * more clear name for segment * use old segment name to not break bc * various fixes * more test fixes * fix no suggested values for new segment * add event value * for boolean dimensions only sum metric * update available widgets when updating reporting menu * Add new segments in developer changelog + typo * fix system tests * fix screenshot test
Diffstat (limited to 'plugins/Goals/Goals.php')
-rw-r--r--plugins/Goals/Goals.php71
1 files changed, 69 insertions, 2 deletions
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 0700d8aa75..b1d10e16f3 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -8,8 +8,13 @@
*/
namespace Piwik\Plugins\Goals;
+use Piwik\Columns\ComputedMetricFactory;
+use Piwik\Columns\Dimension;
+use Piwik\Columns\MetricsList;
use Piwik\Common;
use Piwik\Piwik;
+use Piwik\Plugin\ArchivedMetric;
+use Piwik\Plugin\ComputedMetric;
use Piwik\Plugin\ReportsProvider;
use Piwik\Tracker\GoalManager;
use Piwik\Category\Subcategory;
@@ -77,11 +82,74 @@ class Goals extends \Piwik\Plugin
'SitesManager.deleteSite.end' => 'deleteSiteGoals',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations',
- 'Category.addSubcategories' => 'addSubcategories'
+ 'Category.addSubcategories' => 'addSubcategories',
+ 'Metric.addMetrics' => 'addMetrics',
+ 'Metric.addComputedMetrics' => 'addComputedMetrics'
);
return $hooks;
}
+ public function addComputedMetrics(MetricsList $list, ComputedMetricFactory $computedMetricFactory)
+ {
+ $idSite = Common::getRequestVar('idSite', 0, 'int');
+ $goals = API::getInstance()->getGoals($idSite);
+
+ foreach ($goals as $goal) {
+ $metric = $computedMetricFactory->createComputedMetric('goal_' . $goal['idgoal'] . '_conversion', 'nb_uniq_visitors', ComputedMetric::AGGREGATION_RATE);
+ $goalName = Piwik::translate('Goals_GoalX', $goal['name']);
+ $metricName = Piwik::translate('Goals_ConversionRate', $goalName);
+ $metric->setTranslatedName($metricName);
+ $list->addMetric($metric);
+ }
+ }
+
+ public function addMetrics(MetricsList $metricsList)
+ {
+ $idSite = Common::getRequestVar('idSite', 0, 'int');
+ $goals = API::getInstance()->getGoals($idSite);
+
+ foreach ($goals as $goal) {
+ $custom = new GoalDimension($goal, 'idgoal', 'Conversions goal "' . $goal['name'] . '" (ID ' . $goal['idgoal'] .' )');
+ $custom->setType(Dimension::TYPE_NUMBER);
+ $custom->setSqlSegment('count(distinct log_conversion.idvisit, log_conversion.buster)');
+
+ $metric = new ArchivedMetric($custom, ArchivedMetric::AGGREGATION_SUM);
+ $metric->setQuery('count(distinct log_conversion.idvisit, log_conversion.buster)');
+ $metric->setTranslatedName($custom->getName());
+ $metric->setDocumentation('The number of times this goal was converted.');
+ $metric->setCategory($custom->getCategoryId());
+ $metric->setName('goal_' . $goal['idgoal'] . '_conversion');
+ $metricsList->addMetric($metric);
+
+ $custom = new GoalDimension($goal, 'revenue', 'Revenue goal "' . $goal['name'] . '" (ID ' . $goal['idgoal'] .' )');
+ $custom->setType(Dimension::TYPE_MONEY);
+ $metric = new ArchivedMetric($custom, ArchivedMetric::AGGREGATION_SUM);
+ $metric->setTranslatedName($custom->getName());
+ $metric->setName('goal_' . $goal['idgoal'] . '_revenue');
+ $metric->setDocumentation('The amount of revenue that was generated by converting this goal.');
+ $metric->setCategory($custom->getCategoryId());
+ $metricsList->addMetric($metric);
+
+ $custom = new GoalDimension($goal, 'visitor_days_since_first', 'Days to conversion goal "' . $goal['name'] . '" (ID ' . $goal['idgoal'] .' )');
+ $custom->setType(Dimension::TYPE_NUMBER);
+ $metric = new ArchivedMetric($custom, ArchivedMetric::AGGREGATION_SUM);
+ $metric->setTranslatedName($custom->getName());
+ $metric->setCategory($custom->getCategoryId());
+ $metric->setDocumentation('The number of days it took a visitor to convert this goal.');
+ $metric->setName('goal_' . $goal['idgoal'] . '_daystoconversion');
+ $metricsList->addMetric($metric);
+
+ $custom = new GoalDimension($goal, 'visitor_count_visits', 'Visits to conversion goal "' . $goal['name'] . '" (ID ' . $goal['idgoal'] .' )');
+ $custom->setType(Dimension::TYPE_NUMBER);
+ $metric = new ArchivedMetric($custom, ArchivedMetric::AGGREGATION_SUM);
+ $metric->setTranslatedName($custom->getName());
+ $metric->setCategory($custom->getCategoryId());
+ $metric->setDocumentation('The number of visits it took a visitor to convert this goal.');
+ $metric->setName('goal_' . $goal['idgoal'] . '_visitstoconversion');
+ $metricsList->addMetric($metric);
+ }
+ }
+
public function addSubcategories(&$subcategories)
{
$idSite = Common::getRequestVar('idSite', 0, 'int');
@@ -108,7 +176,6 @@ class Goals extends \Piwik\Plugin
}
}
-
public function addMetricTranslations(&$translations)
{
$metrics = array(