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:
Diffstat (limited to 'plugins/Referrers/Columns/Campaign.php')
-rw-r--r--plugins/Referrers/Columns/Campaign.php51
1 files changed, 48 insertions, 3 deletions
diff --git a/plugins/Referrers/Columns/Campaign.php b/plugins/Referrers/Columns/Campaign.php
index 4413cd702f..53f86e97eb 100644
--- a/plugins/Referrers/Columns/Campaign.php
+++ b/plugins/Referrers/Columns/Campaign.php
@@ -8,13 +8,58 @@
*/
namespace Piwik\Plugins\Referrers\Columns;
-use Piwik\Columns\Dimension;
+use Piwik\Common;
use Piwik\Piwik;
+use Piwik\Tracker\Action;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\TrackerConfig;
+use Piwik\Tracker\Visitor;
-class Campaign extends Dimension
+class Campaign extends Base
{
+ /**
+ * Obtained from the `[Tracker] tracker_create_new_visit_when_campaign_changes` INI config option.
+ * If true, will create new visits when campaign name changes.
+ *
+ * @var bool
+ */
+ protected $createNewVisitWhenCampaignChanges;
+
+ public function __construct()
+ {
+ $this->createNewVisitWhenCampaignChanges = TrackerConfig::getConfigValue('tracker_create_new_visit_when_campaign_changes') == 1;
+ }
+
public function getName()
{
return Piwik::translate('Referrers_ColumnCampaign');
}
-}
+
+ /**
+ * If we should create a new visit when the campaign changes, check if the campaign info changed and if so
+ * force the tracker to create a new visit.
+ *
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @return bool
+ */
+ public function shouldForceNewVisit(Request $request, Visitor $visitor, Action $action = null)
+ {
+ if (!$this->createNewVisitWhenCampaignChanges) {
+ return false;
+ }
+
+ $information = $this->getReferrerInformationFromRequest($request);
+
+ if ($this->doesLastOrCurrentActionHaveSameReferrer($visitor, $information, Common::REFERRER_TYPE_CAMPAIGN)
+ && $this->hasReferrerInformationChanged($visitor, $information)
+ ) {
+ Common::printDebug("Existing visit detected, but creating new visit because campaign information is different than last action.");
+
+ return true;
+ }
+
+ return false;
+ }
+} \ No newline at end of file