-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatomoWireConfig.php
144 lines (129 loc) · 5.96 KB
/
MatomoWireConfig.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php namespace ProcessWire;
class MatomoWireConfig extends ModuleConfig
{
public function getDefaults()
{
return [
'matomo_url' => '',
'embedding_method' => 'site',
'render_position' => 'body',
'site_id' => '',
'container_id' => '',
'set_do_not_track' => false,
'disable_cookies' => false,
'integrate_privacywire' => false,
'privacywire_cookie_category' => 'statistics',
'opt_out_type' => 'iframe'
];
}
public function getInputfields()
{
$inputfields = parent::getInputfields();
// Matomo URL
$f = $this->modules->get('InputfieldURL');
$f->attr('name', 'matomo_url');
$f->label = $this->_('Matomo URL');
$f->description = $this->_('Insert the full URL including http:// or https://');
$f->columnWidth = 33;
$inputfields->add($f);
// Embedding Method
$f = $this->modules->get('InputfieldSelect');
$f->attr('name', 'embedding_method');
$f->description = $this->_("Choose between the classical matomo site tracking or via Matomo Tag Manager");
$f->label = $this->_('Embedding Method');
$f->options = [
"site" => $this->_("Site Tracking"),
"tag" => $this->_("Matomo Tag Manager Tracking"),
];
$f->columnWidth = 33;
$f->required = 1;
$inputfields->add($f);
// Rendering Position
$f = $this->modules->get('InputfieldSelect');
$f->attr('name', 'render_position');
$f->description = $this->_("Choose between rendering within <head> or within <body>.");
$f->label = $this->_('Rendering Position');
$f->options = [
"head" => $this->_("<head>"),
"body" => $this->_("<body>"),
];
$f->columnWidth = 34;
$inputfields->add($f);
// Site Id
$f = $this->modules->get('InputfieldText');
$f->attr('name', 'site_id');
$f->label = $this->_('Site Id');
$f->columnWidth = 100;
$f->showIf("embedding_method=site");
$inputfields->add($f);
// Container Id
$f = $this->modules->get('InputfieldText');
$f->attr('name', 'container_id');
$f->label = $this->_('Container Id');
$f->columnWidth = 100;
$f->showIf("embedding_method=tag");
$inputfields->add($f);
// Site Tracking: Respect DoNotTrack (DNT)
$f = $this->modules->get('InputfieldCheckbox');
$f->attr('name', 'set_do_not_track');
$f->showIf("embedding_method=site");
$f->label = $this->_('Respect Do-Not-Track');
$f->columnWidth = 50;
$inputfields->add($f);
// Site Tracking: Disable Cookies
$f = $this->modules->get('InputfieldCheckbox');
$f->attr('name', 'disable_cookies');
$f->description = $this->_('It is possible to track users [without cookies](https://matomo.org/faq/new-to-piwik/how-do-i-use-matomo-analytics-without-consent-or-cookie-banner/) - [the data accuracy is impacted](https://matomo.org/faq/general/faq_156/)');
$f->showIf("embedding_method=site");
$f->label = $this->_('Disable Cookies');
$f->columnWidth = 50;
$inputfields->add($f);
// Fieldset for PrivacyWire Integration
$privacywireIsInstalled = $this->modules->isInstalled('PrivacyWire');
$privacywire_integration = $this->modules->get('InputfieldFieldset');
$privacywire_integration->label = $this->_('PrivacyWire Integration');
if(!$privacywireIsInstalled) {
$privacywire_integration->collapsed = Inputfield::collapsedNoLocked; // Inputfield::collapsedLocked
$privacywire_integration->description = $this->_('**Important:** PrivacyWire needs to be installed to enable this feature!') . ' ([https://github.com/blaueQuelle/privacywire](https://github.com/blaueQuelle/privacywire))';
}
$inputfields->add($privacywire_integration);
// Enable PrivacyWire Integration
$f = $this->modules->get('InputfieldCheckbox');
$f->attr('name', 'integrate_privacywire');
$f->label = $this->_('Enable PrivacyWire Integration');
$f->columnWidth = 33;
if(!$privacywireIsInstalled) $f->collapsed = Inputfield::collapsedLocked;
$privacywire_integration->add($f);
// PrivacyWire Cookie Category
$f = $this->modules->get('InputfieldSelect');
$f->attr('name', 'privacywire_cookie_category');
$f->showIf("integrate_privacywire=1");
$f->description = $this->_("Choose, which PrivacyWire Cookie Category should trigger the Matomo Integration");
$f->label = $this->_('PrivacyWire Cookie Category');
$f->options = [
"necessary" => $this->_("Necessary Cookies"),
"functional" => $this->_("Functional Cookies"),
"all" => $this->_("All Cookies"),
"statistics" => $this->_("Statistics"),
'marketing' => $this->_("Marketing"),
'external_media' => $this->_("External Media")
];
$f->columnWidth = 33;
if(!$privacywireIsInstalled) $f->collapsed = Inputfield::collapsedLocked;
$privacywire_integration->add($f);
// PrivacyWire Cookie Category
$f = $this->modules->get('InputfieldSelect');
$f->attr('name', 'opt_out_type');
$f->showIf("integrate_privacywire=1");
$f->label = $this->_('Matomo Opt-Out Type');
$f->description = $this->_("Should the Opt-Out Tag (Textformatter) trigger the Matomo iFrame Opt-Out (default) or the PrivacyWire Choose-Cookies-Window?");
$f->options = [
"iframe" => $this->_("Matomo iFrame (default)"),
"privacywire" => $this->_("PrivacyWire Choose-Cookies-Window"),
];
$f->columnWidth = 34;
if(!$privacywireIsInstalled) $f->collapsed = Inputfield::collapsedLocked;
$privacywire_integration->add($f);
return $inputfields;
}
}