-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathVisitorDetails.php
62 lines (54 loc) · 2.3 KB
/
VisitorDetails.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\MarketingCampaignsReporting;
use Piwik\Piwik;
use Piwik\Plugins\Live\VisitorDetailsAbstract;
use Piwik\View;
class VisitorDetails extends VisitorDetailsAbstract
{
public function extendVisitorDetails(&$visitor)
{
$fields = array(
'campaignId' => 'campaign_id',
'campaignContent' => 'campaign_content',
'campaignKeyword' => 'campaign_keyword',
'campaignMedium' => 'campaign_medium',
'campaignName' => 'campaign_name',
'campaignSource' => 'campaign_source',
'campaignGroup' => 'campaign_group',
'campaignPlacement' => 'campaign_placement',
);
foreach ($fields as $name => $field) {
$visitor[$name] = empty($this->details[$field]) ? '' : $this->details[$field];
}
}
public function renderVisitorDetails($visitorDetails)
{
$campaignData = [];
$fields = array(
'campaignId' => Piwik::translate('MarketingCampaignsReporting_CampaignId'),
'campaignName' => Piwik::translate('MarketingCampaignsReporting_Name'),
'campaignMedium' => Piwik::translate('MarketingCampaignsReporting_Medium'),
'campaignContent' => Piwik::translate('MarketingCampaignsReporting_Content'),
'campaignKeyword' => Piwik::translate('MarketingCampaignsReporting_Keyword'),
'campaignSource' => Piwik::translate('MarketingCampaignsReporting_Source'),
'campaignGroup' => Piwik::translate('MarketingCampaignsReporting_Group'),
'campaignPlacement' => Piwik::translate('MarketingCampaignsReporting_Placement'),
);
foreach ($fields as $field => $name) {
if (!empty($visitorDetails[$field])) {
$campaignData[$name] = html_entity_decode($visitorDetails[$field], ENT_QUOTES, 'UTF-8');
}
}
$view = new View('@MarketingCampaignsReporting/visitorDetails');
$view->sendHeadersWhenRendering = false;
$view->campaign = $campaignData;
return [[30, $view->render()]];
}
}