diff options
author | diosmosis <benaka@piwik.pro> | 2015-07-08 06:44:52 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-08-06 17:37:57 +0300 |
commit | c7146884d703e99d7c57822aed0a58a04da37402 (patch) | |
tree | 31bd4115d2ef7a5cf4fdeac74de7e29fff26705c /plugins | |
parent | 34d4ab4177e14c53f0fc42509efe6bd397114ed1 (diff) |
Moving ecommerce detection logic to new EcommerceRequestProcessor class from Visit::handle().
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php | 34 | ||||
-rw-r--r-- | plugins/Ecommerce/config/config.php | 9 |
2 files changed, 43 insertions, 0 deletions
diff --git a/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php new file mode 100644 index 0000000000..b5f0064728 --- /dev/null +++ b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php @@ -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\Ecommerce\Tracker; + +use Piwik\Tracker\GoalManager; +use Piwik\Tracker\Request; +use Piwik\Tracker\RequestProcessor; +use Piwik\Tracker\Visit\VisitProperties; + +/** + * TODO + */ +class EcommerceRequestProcessor extends RequestProcessor +{ + public function processRequestParams(VisitProperties $visitProperties, Request $request) + { + $goalManager = new GoalManager($request); // TODO: GoalManager should be stateless and stored in DI. + + if ($goalManager->requestIsEcommerce) { + $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', true); + + // Mark the visit as Converted only if it is an order (not for a Cart update) + if ($goalManager->isGoalAnOrder()) { + $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', true); + } + } + } +}
\ No newline at end of file diff --git a/plugins/Ecommerce/config/config.php b/plugins/Ecommerce/config/config.php new file mode 100644 index 0000000000..3431748e41 --- /dev/null +++ b/plugins/Ecommerce/config/config.php @@ -0,0 +1,9 @@ +<?php + +return array( + + 'tracker.request.processors' => DI\add(array( + DI\get('Piwik\Plugins\Ecommerce\Tracker\EcommerceRequestProcessor'), + )), + +); |