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 <thomas.steur@googlemail.com>2014-08-07 14:08:15 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-08-07 14:08:15 +0400
commit2326ce5d843e816779838356be7db84b72ec9cf0 (patch)
treeee057dedbe577d6674d1e16051238f576e90ad98 /plugins
parent2a52246eda52b963798de26a931a629da299a8ce (diff)
parentb165f6b99a99eecefffb304a791b579a00c64370 (diff)
Merge branch 'master' into 5896_add_generic_filters_to_arrays
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CoreConsole/Commands/GenerateDimension.php6
-rw-r--r--plugins/CoreConsole/Commands/GenerateReport.php6
-rw-r--r--plugins/ExampleReport/API.php38
-rw-r--r--plugins/ExampleReport/ExampleReport.php13
-rw-r--r--plugins/ExampleReport/Reports/Base.php19
-rw-r--r--plugins/ExampleReport/Reports/GetExampleReport.php116
-rw-r--r--plugins/ExampleReport/plugin.json13
-rw-r--r--plugins/ExampleTracker/Columns/ExampleActionDimension.php136
-rw-r--r--plugins/ExampleTracker/Columns/ExampleConversionDimension.php133
-rw-r--r--plugins/ExampleTracker/Columns/ExampleDimension.php30
-rw-r--r--plugins/ExampleTracker/Columns/ExampleVisitDimension.php157
-rw-r--r--plugins/ExampleTracker/ExampleTracker.php13
-rw-r--r--plugins/ExampleTracker/lang/en.json (renamed from plugins/ExamplePlugin/lang/en.json)2
-rw-r--r--plugins/ExampleTracker/plugin.json13
-rw-r--r--plugins/VisitsSummary/Controller.php10
15 files changed, 693 insertions, 12 deletions
diff --git a/plugins/CoreConsole/Commands/GenerateDimension.php b/plugins/CoreConsole/Commands/GenerateDimension.php
index 0c11020b26..269632100e 100644
--- a/plugins/CoreConsole/Commands/GenerateDimension.php
+++ b/plugins/CoreConsole/Commands/GenerateDimension.php
@@ -52,7 +52,7 @@ class GenerateDimension extends GeneratePluginBase
$dimensionClassName = $this->getDimensionClassName($dimensionName);
$translatedDimensionName = $this->makeTranslationIfPossible($pluginName, ucfirst($dimensionName));
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleTracker';
$replace = array('example_action_dimension' => strtolower($columnName),
'example_visit_dimension' => strtolower($columnName),
'example_conversion_dimension' => strtolower($columnName),
@@ -62,8 +62,8 @@ class GenerateDimension extends GeneratePluginBase
'ExampleVisitDimension' => $dimensionClassName,
'ExampleActionDimension' => $dimensionClassName,
'ExampleConversionDimension' => $dimensionClassName,
- 'ExamplePlugin_DimensionName' => $translatedDimensionName,
- 'ExamplePlugin' => $pluginName,
+ 'ExampleTracker_DimensionName' => $translatedDimensionName,
+ 'ExampleTracker' => $pluginName,
);
$whitelistFiles = array('/Columns');
diff --git a/plugins/CoreConsole/Commands/GenerateReport.php b/plugins/CoreConsole/Commands/GenerateReport.php
index 84677f10db..7a678c270a 100644
--- a/plugins/CoreConsole/Commands/GenerateReport.php
+++ b/plugins/CoreConsole/Commands/GenerateReport.php
@@ -39,8 +39,8 @@ class GenerateReport extends GeneratePluginBase
$order = $this->getOrder($category);
$apiName = $this->getApiName($reportName);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
- $replace = array('ExamplePlugin' => $pluginName,
+ $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleReport';
+ $replace = array('ExampleReport' => $pluginName,
'GetExampleReport' => ucfirst($apiName),
'getExampleReport' => lcfirst($apiName),
'getApiReport' => lcfirst($apiName),
@@ -55,7 +55,7 @@ class GenerateReport extends GeneratePluginBase
$whitelistFiles = array('/Reports', '/Reports/Base.php', '/Reports/GetExampleReport.php');
if (file_exists($this->getPluginPath($pluginName) . '/API.php')) {
- $this->copyTemplateMethodToExisitingClass('Piwik\Plugins\ExamplePlugin\API', 'getExampleReport', $replace);
+ $this->copyTemplateMethodToExisitingClass('Piwik\Plugins\ExampleReport\API', 'getExampleReport', $replace);
} else {
$whitelistFiles[] = '/API.php';
}
diff --git a/plugins/ExampleReport/API.php b/plugins/ExampleReport/API.php
new file mode 100644
index 0000000000..3c7c3866c4
--- /dev/null
+++ b/plugins/ExampleReport/API.php
@@ -0,0 +1,38 @@
+<?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\ExampleReport;
+
+use Piwik\DataTable;
+use Piwik\DataTable\Row;
+
+/**
+ * API for plugin ExampleReport
+ *
+ * @method static \Piwik\Plugins\ExampleReport\API getInstance()
+ */
+class API extends \Piwik\Plugin\API
+{
+
+ /**
+ * Another example method that returns a data table.
+ * @param int $idSite
+ * @param string $period
+ * @param string $date
+ * @param bool|string $segment
+ * @return DataTable
+ */
+ public function getExampleReport($idSite, $period, $date, $segment = false)
+ {
+ $table = new DataTable();
+
+ $table->addRowFromArray(array(Row::COLUMNS => array('nb_visits' => 5)));
+
+ return $table;
+ }
+}
diff --git a/plugins/ExampleReport/ExampleReport.php b/plugins/ExampleReport/ExampleReport.php
new file mode 100644
index 0000000000..b1d2d1c708
--- /dev/null
+++ b/plugins/ExampleReport/ExampleReport.php
@@ -0,0 +1,13 @@
+<?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\ExampleReport;
+
+class ExampleReport extends \Piwik\Plugin
+{
+}
diff --git a/plugins/ExampleReport/Reports/Base.php b/plugins/ExampleReport/Reports/Base.php
new file mode 100644
index 0000000000..c09da78e4b
--- /dev/null
+++ b/plugins/ExampleReport/Reports/Base.php
@@ -0,0 +1,19 @@
+<?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\ExampleReport\Reports;
+
+use Piwik\Plugin\Report;
+
+abstract class Base extends Report
+{
+ protected function init()
+ {
+ $this->category = 'ExampleCategory';
+ }
+}
diff --git a/plugins/ExampleReport/Reports/GetExampleReport.php b/plugins/ExampleReport/Reports/GetExampleReport.php
new file mode 100644
index 0000000000..408ba9a23d
--- /dev/null
+++ b/plugins/ExampleReport/Reports/GetExampleReport.php
@@ -0,0 +1,116 @@
+<?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\ExampleReport\Reports;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Report;
+use Piwik\Plugin\ViewDataTable;
+use Piwik\Plugins\Actions\Columns\ExitPageUrl;
+use Piwik\View;
+
+/**
+ * This class defines a new report.
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
+ */
+class GetExampleReport extends Base
+{
+ protected function init()
+ {
+ parent::init();
+
+ $this->name = Piwik::translate('ExampleReportName');
+ $this->dimension = new ExitPageUrl();
+ $this->documentation = Piwik::translate('ExampleReportDocumentation');
+
+ // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
+ $this->order = 999;
+
+ // By default standard metrics are defined but you can customize them by defining an array of metric names
+ // $this->metrics = array('nb_visits', 'nb_hits');
+
+ // Uncomment the next line if your report does not contain any processed metrics, otherwise default
+ // processed metrics will be assigned
+ // $this->processedMetrics = array();
+
+ // Uncomment the next line if your report defines goal metrics
+ // $this->hasGoalMetrics = true;
+
+ // Uncomment the next line if your report should be able to load subtables. You can define any action here
+ // $this->actionToLoadSubTables = $this->action;
+
+ // Uncomment the next line if your report always returns a constant count of rows, for instance always
+ // 24 rows for 1-24hours
+ // $this->constantRowsCount = true;
+
+ // If a menu title is specified, the report will be displayed in the menu
+ // $this->menuTitle = 'ExampleReportName';
+
+ // If a widget title is specified, the report will be displayed in the list of widgets and the report can be
+ // exported as a widget
+ // $this->widgetTitle = 'ExampleReportName';
+ }
+
+ /**
+ * Here you can configure how your report should be displayed. For instance whether your report supports a search
+ * etc. You can also change the default request config. For instance change how many rows are displayed by default.
+ *
+ * @param ViewDataTable $view
+ */
+ public function configureView(ViewDataTable $view)
+ {
+ if (!empty($this->dimension)) {
+ $view->config->addTranslations(array('label' => $this->dimension->getName()));
+ }
+
+ // $view->config->show_search = false;
+ // $view->requestConfig->filter_sort_column = 'nb_visits';
+ // $view->requestConfig->filter_limit = 10';
+
+ $view->config->columns_to_display = array_merge(array('label'), $this->metrics);
+ }
+
+ /**
+ * Here you can define related reports that will be shown below the reports. Just return an array of related
+ * report instances if there are any.
+ *
+ * @return \Piwik\Plugin\Report[]
+ */
+ public function getRelatedReports()
+ {
+ return array(); // eg return array(new XyzReport());
+ }
+
+ /**
+ * A report is usually completely automatically rendered for you but you can render the report completely
+ * customized if you wish. Just overwrite the method and make sure to return a string containing the content of the
+ * report. Don't forget to create the defined twig template within the templates folder of your plugin in order to
+ * make it work. Usually you should NOT have to overwrite this render method.
+ *
+ * @return string
+ public function render()
+ {
+ $view = new View('@ExampleReport/getExampleReport');
+ $view->myData = array();
+
+ return $view->render();
+ }
+ */
+
+ /**
+ * By default your report is available to all users having at least view access. If you do not want this, you can
+ * limit the audience by overwriting this method.
+ *
+ * @return bool
+ public function isEnabled()
+ {
+ return Piwik::hasUserSuperUserAccess()
+ }
+ */
+}
diff --git a/plugins/ExampleReport/plugin.json b/plugins/ExampleReport/plugin.json
new file mode 100644
index 0000000000..92b90becb4
--- /dev/null
+++ b/plugins/ExampleReport/plugin.json
@@ -0,0 +1,13 @@
+{
+ "name": "ExampleReport",
+ "version": "0.1.0",
+ "description": "A plugin that shows how to define a report",
+ "theme": false,
+ "authors": [
+ {
+ "name": "Piwik",
+ "email": "",
+ "homepage": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/plugins/ExampleTracker/Columns/ExampleActionDimension.php b/plugins/ExampleTracker/Columns/ExampleActionDimension.php
new file mode 100644
index 0000000000..b0ce98f7c9
--- /dev/null
+++ b/plugins/ExampleTracker/Columns/ExampleActionDimension.php
@@ -0,0 +1,136 @@
+<?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\ExampleTracker\Columns;
+
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugin\Dimension\ActionDimension;
+use Piwik\Plugin\Segment;
+use Piwik\Tracker\ActionPageview;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\Visitor;
+use Piwik\Tracker\Action;
+
+/**
+ * This example dimension recognizes a new tracking url parameter that is supposed to save the keywords that were used
+ * on a certain page. Please note that dimension instances are usually cached during one tracking request so they
+ * should be stateless (meaning an instance of this dimension will be reused if requested multiple times).
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin\Dimension\ActionDimension} for more information.
+ */
+class ExampleActionDimension extends ActionDimension
+{
+ /**
+ * This will be the name of the column in the log_link_visit_action table if a $columnType is specified.
+ * @var string
+ */
+ protected $columnName = 'example_action_dimension';
+
+ /**
+ * If a columnType is defined, we will create this a column in the MySQL table having this type. Please make sure
+ * MySQL will understand this type. Once you change the column type the Piwik platform will notify the user to
+ * perform an update which can sometimes take a long time so be careful when choosing the correct column type.
+ * @var string
+ */
+ protected $columnType = 'VARCHAR(255) DEFAULT NULL';
+
+ /**
+ * The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
+ * @return string
+ */
+ public function getName()
+ {
+ return Piwik::translate('ExampleTracker_DimensionName');
+ }
+
+ /**
+ * By defining one or multiple segments a user will be able to filter their visitors by this column. For instance
+ * show all actions only considering users having more than 10 achievement points. If you do not want to define a
+ * segment for this dimension just remove the column.
+ */
+ protected function configureSegments()
+ {
+ $segment = new Segment();
+ $segment->setSegment('keywords');
+ $segment->setCategory('General_Actions');
+ $segment->setName('ExampleTracker_DimensionName');
+ $segment->setAcceptedValues('Here you should explain which values are accepted/useful: Any word, for instance MyKeyword1, MyKeyword2');
+ $this->addSegment($segment);
+ }
+
+ /**
+ * This event is triggered before a new action is logged to the log_link_visit_action table. It overwrites any
+ * looked up action so it makes usually no sense to implement both methods but it sometimes does. You can assign
+ * any value to the column or return boolan false in case you do not want to save any value.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action $action
+ *
+ * @return mixed|false
+ */
+ public function onNewAction(Request $request, Visitor $visitor, Action $action)
+ {
+ if (!($action instanceof ActionPageview)) {
+ // save value only in case it is a page view.
+ return false;
+ }
+
+ $value = Common::getRequestVar('my_page_keywords', false, 'string', $request->getParams());
+
+ if (false === $value) {
+ return $value;
+ }
+
+ $value = trim($value);
+
+ return substr($value, 0, 255);
+ }
+
+ /**
+ * If the value you want to save for your dimension is something like a page title or page url, you usually do not
+ * want to save the raw value over and over again to save bytes in the database. Instead you want to save each value
+ * once in the log_action table and refer to this value by its ID in the log_link_visit_action table. You can do
+ * this by returning an action id in "getActionId()" and by returning a value here. If a value should be ignored
+ * or not persisted just return boolean false. Please note if you return a value here and you implement the event
+ * "onNewAction" the value will be probably overwritten by the other event. So make sure to implement only one of
+ * those.
+ *
+ * @param Request $request
+ * @param Action $action
+ *
+ * @return false|mixed
+ public function onLookupAction(Request $request, Action $action)
+ {
+ if (!($action instanceof ActionPageview)) {
+ // save value only in case it is a page view.
+ return false;
+ }
+
+ $value = Common::getRequestVar('my_page_keywords', false, 'string', $request->getParams());
+
+ if (false === $value) {
+ return $value;
+ }
+
+ $value = trim($value);
+
+ return substr($value, 0, 255);
+ }
+ */
+
+ /**
+ * An action id. The value returned by the lookup action will be associated with this id in the log_action table.
+ * @return int
+ public function getActionId()
+ {
+ return Action::TYPE_PAGE_URL;
+ }
+ */
+} \ No newline at end of file
diff --git a/plugins/ExampleTracker/Columns/ExampleConversionDimension.php b/plugins/ExampleTracker/Columns/ExampleConversionDimension.php
new file mode 100644
index 0000000000..3e24008449
--- /dev/null
+++ b/plugins/ExampleTracker/Columns/ExampleConversionDimension.php
@@ -0,0 +1,133 @@
+<?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\ExampleTracker\Columns;
+
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugin\Dimension\ConversionDimension;
+use Piwik\Plugin\Segment;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\Visitor;
+use Piwik\Tracker\Action;
+use Piwik\Tracker\GoalManager;
+
+/**
+ * This example dimension counts achievement points for each user. A user gets one achievement point for each action
+ * plus five extra achievement points for each conversion. This would allow you to create a ranking showing the most
+ * active/valueable users. It is just an example, you can log pretty much everything and even just store any custom
+ * request url property. Please note that dimension instances are usually cached during one tracking request so they
+ * should be stateless (meaning an instance of this dimension will be reused if requested multiple times).
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin\Dimension\ConversionDimension} for more information.
+ */
+class ExampleConversionDimension extends ConversionDimension
+{
+ /**
+ * This will be the name of the column in the log_conversion table if a $columnType is specified.
+ * @var string
+ */
+ protected $columnName = 'example_conversion_dimension';
+
+ /**
+ * If a columnType is defined, we will create this a column in the MySQL table having this type. Please make sure
+ * MySQL will understand this type. Once you change the column type the Piwik platform will notify the user to
+ * perform an update which can sometimes take a long time so be careful when choosing the correct column type.
+ * @var string
+ */
+ protected $columnType = 'INTEGER(11) DEFAULT 0 NOT NULL';
+
+ /**
+ * The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
+ * @return string
+ */
+ public function getName()
+ {
+ return Piwik::translate('ExampleTracker_DimensionName');
+ }
+
+ /**
+ * By defining one or multiple segments a user will be able to filter their visitors by this column. For instance
+ * show all reports only considering users having more than 10 achievement points. If you do not want to define a
+ * segment for this dimension just remove the column.
+ */
+ protected function configureSegments()
+ {
+ $segment = new Segment();
+ $segment->setSegment('myConversionSegmentName');
+ $segment->setCategory('General_Visit');
+ $segment->setName('ExampleTracker_DimensionName');
+ $segment->setAcceptedValues('Here you should explain which values are accepted/useful: Any number, for instance 1, 2, 3 , 99');
+ $this->addSegment($segment);
+ }
+
+ /**
+ * This event is triggered when an ecommerce order is converted. In this example we would store a "0" in case it
+ * was the visitors first action or "1" otherwise.
+ * Return boolean false if you do not want to change the value in some cases. If you do not want to perform any
+ * action on an ecommerce order at all it is recommended to just remove this method.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @param GoalManager $goalManager
+ *
+ * @return mixed|false
+ */
+ public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
+ {
+ if ($visitor->isVisitorKnown()) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ /**
+ * This event is triggered when an ecommerce cart update is converted. In this example we would store a
+ * the value of the tracking url parameter "myCustomParam" in the "example_conversion_dimension" column.
+ * Return boolean false if you do not want to change the value in some cases. If you do not want to perform any
+ * action on an ecommerce order at all it is recommended to just remove this method.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @param GoalManager $goalManager
+ *
+ * @return mixed|false
+ */
+ public function onEcommerceCartUpdateConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
+ {
+ return Common::getRequestVar('myCustomParam', $default = false, 'int', $request->getParams());
+ }
+
+ /**
+ * This event is triggered when an any custom goal is converted. In this example we would store a the id of the
+ * goal in the 'example_conversion_dimension' column if the visitor is known and nothing otherwise.
+ * Return boolean false if you do not want to change the value in some cases. If you do not want to perform any
+ * action on an ecommerce order at all it is recommended to just remove this method.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @param GoalManager $goalManager
+ *
+ * @return mixed|false
+ */
+ public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
+ {
+ $goalId = $goalManager->getGoalColumn('idgoal');
+
+ if ($visitor->isVisitorKnown()) {
+ return $goalId;
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/ExampleTracker/Columns/ExampleDimension.php b/plugins/ExampleTracker/Columns/ExampleDimension.php
new file mode 100644
index 0000000000..738d0be9e1
--- /dev/null
+++ b/plugins/ExampleTracker/Columns/ExampleDimension.php
@@ -0,0 +1,30 @@
+<?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\ExampleTracker\Columns;
+
+use Piwik\Columns\Dimension;
+use Piwik\Piwik;
+
+/**
+ * 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 ExampleDimension extends Dimension
+{
+
+ /**
+ * The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
+ * @return string
+ */
+ public function getName()
+ {
+ return Piwik::translate('ExampleTracker_DimensionName');
+ }
+} \ No newline at end of file
diff --git a/plugins/ExampleTracker/Columns/ExampleVisitDimension.php b/plugins/ExampleTracker/Columns/ExampleVisitDimension.php
new file mode 100644
index 0000000000..d47d98eb59
--- /dev/null
+++ b/plugins/ExampleTracker/Columns/ExampleVisitDimension.php
@@ -0,0 +1,157 @@
+<?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\ExampleTracker\Columns;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Dimension\VisitDimension;
+use Piwik\Plugin\Segment;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\Visitor;
+use Piwik\Tracker\Action;
+
+/**
+ * This example dimension counts achievement points for each user. A user gets one achievement point for each action
+ * plus five extra achievement points for each conversion. This would allow you to create a ranking showing the most
+ * active/valueable users. It is just an example, you can log pretty much everything and even just store any custom
+ * request url property. Please note that dimension instances are usually cached during one tracking request so they
+ * should be stateless (meaning an instance of this dimension will be reused if requested multiple times).
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin\Dimension\VisitDimension} for more information.
+ */
+class ExampleVisitDimension extends VisitDimension
+{
+ /**
+ * This will be the name of the column in the log_visit table if a $columnType is specified.
+ * @var string
+ */
+ protected $columnName = 'example_visit_dimension';
+
+ /**
+ * If a columnType is defined, we will create this a column in the MySQL table having this type. Please make sure
+ * MySQL will understand this type. Once you change the column type the Piwik platform will notify the user to
+ * perform an update which can sometimes take a long time so be careful when choosing the correct column type.
+ * @var string
+ */
+ protected $columnType = 'INTEGER(11) DEFAULT 0 NOT NULL';
+
+ /**
+ * The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
+ * @return string
+ */
+ public function getName()
+ {
+ return Piwik::translate('ExampleTracker_DimensionName');
+ }
+
+ /**
+ * By defining one or multiple segments a user will be able to filter their visitors by this column. For instance
+ * show all reports only considering users having more than 10 achievement points. If you do not want to define a
+ * segment for this dimension just remove the column.
+ */
+ protected function configureSegments()
+ {
+ $segment = new Segment();
+ $segment->setSegment('achievementPoints');
+ $segment->setCategory('General_Visit');
+ $segment->setName('ExampleTracker_DimensionName');
+ $segment->setAcceptedValues('Here you should explain which values are accepted/useful: Any number, for instance 1, 2, 3 , 99');
+ $this->addSegment($segment);
+ }
+
+ /**
+ * The onNewVisit method is triggered when a new visitor is detected. This means here you can define an initial
+ * value for this user. By returning boolean false no value will be saved. Once the user makes another action the
+ * event "onExistingVisit" is executed. That means for each visitor this method is executed once. If you do not want
+ * to perform any action on a new visit you can just remove this method.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @return mixed|false
+ */
+ public function onNewVisit(Request $request, Visitor $visitor, $action)
+ {
+ if (empty($action)) {
+ return 0;
+ }
+
+ return 1;
+
+ // you could also easily save any custom tracking url parameters
+ // return Common::getRequestVar('myCustomTrackingParam', 'default', 'string', $request->getParams());
+ // return Common::getRequestVar('linuxversion', false, 'string', $request->getParams());
+ }
+
+ /**
+ * The onExistingVisit method is triggered when a visitor was recognized meaning it is not a new visitor.
+ * If you want you can overwrite any previous value set by the event onNewVisit. By returning boolean false no value
+ * will be updated. If you do not want to perform any action on a new visit you can just remove this method.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ *
+ * @return mixed|false
+ */
+ public function onExistingVisit(Request $request, Visitor $visitor, $action)
+ {
+ if (empty($action)) {
+ return false; // Do not change an already persisted value
+ }
+
+ return $visitor->getVisitorColumn($this->columnName) + 1;
+ }
+
+ /**
+ * This event is executed shortly after "onNewVisit" or "onExistingVisit" in case the visitor converted a goal.
+ * In this example we give the user 5 extra points for this achievement. Usually this event is not needed and you
+ * can simply remove this method therefore. An example would be for instance to persist the last converted
+ * action url. Return boolean false if you do not want to change the current value.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ *
+ * @return mixed|false
+ */
+ public function onConvertedVisit(Request $request, Visitor $visitor, $action)
+ {
+ return $visitor->getVisitorColumn($this->columnName) + 5; // give this visitor 5 extra achievement points
+ }
+
+ /**
+ * By implementing this event you can persist a value to the log_conversion table in case a conversion happens.
+ * The persisted value will be logged along the conversion and will not be changed afterwards.
+ * This allows you to generate reports that shows for instance which url was called how often for a specific
+ * conversion. Once you implement this event and a $columnType is defined a column in the log_conversion MySQL table
+ * will be created automatically.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ *
+ * @return mixed
+ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
+ {
+ return $visitor->getVisitorColumn($this->columnName);
+ }
+ */
+
+ /**
+ * Sometimes you may want to make sure another dimension is executed before your dimension so you can persist
+ * a value depending on the value of other dimensions. You can do this by defining an array of dimension names.
+ * If you access any value of any other column within your events, you should require them here. Otherwise those
+ * values may not be available.
+ * @return array
+ public function getRequiredVisitFields()
+ {
+ return array('idsite', 'server_time');
+ }
+ */
+} \ No newline at end of file
diff --git a/plugins/ExampleTracker/ExampleTracker.php b/plugins/ExampleTracker/ExampleTracker.php
new file mode 100644
index 0000000000..66c2dd95b5
--- /dev/null
+++ b/plugins/ExampleTracker/ExampleTracker.php
@@ -0,0 +1,13 @@
+<?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\ExampleTracker;
+
+class ExampleTracker extends \Piwik\Plugin
+{
+}
diff --git a/plugins/ExamplePlugin/lang/en.json b/plugins/ExampleTracker/lang/en.json
index 3ec2fab503..f270876f33 100644
--- a/plugins/ExamplePlugin/lang/en.json
+++ b/plugins/ExampleTracker/lang/en.json
@@ -1,5 +1,5 @@
{
- "ExamplePlugin": {
+ "ExampleTracker": {
"DimensionName": "Example Dimension"
}
} \ No newline at end of file
diff --git a/plugins/ExampleTracker/plugin.json b/plugins/ExampleTracker/plugin.json
new file mode 100644
index 0000000000..36dcc32096
--- /dev/null
+++ b/plugins/ExampleTracker/plugin.json
@@ -0,0 +1,13 @@
+{
+ "name": "ExampleTracker",
+ "version": "0.1.0",
+ "description": "A plugin that shows how to track additional data",
+ "theme": false,
+ "authors": [
+ {
+ "name": "Piwik",
+ "email": "",
+ "homepage": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php
index 8726ae9d67..1919fd325b 100644
--- a/plugins/VisitsSummary/Controller.php
+++ b/plugins/VisitsSummary/Controller.php
@@ -102,13 +102,13 @@ class Controller extends \Piwik\Plugin\Controller
public static function getVisitsSummary()
{
- $requestString = "method=VisitsSummary.get" .
- "&format=original" .
+ $result = Request::processRequest("VisitsSummary.get", array(
// we disable filters for example "search for pattern", in the case this method is called
// by a method that already calls the API with some generic filters applied
- "&disable_generic_filters=1";
- $request = new Request($requestString);
- $result = $request->process();
+ 'disable_generic_filters' => 1,
+ 'columns' => false
+ ));
+
return empty($result) ? new DataTable() : $result;
}