PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.3.3
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.3.3
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / Admin / views / tracking.php
matomo / classes / WpMatomo / Admin / views Last commit date
access.php 2 years ago advanced_settings.php 1 year ago exclusion_settings.php 4 years ago geolocation_settings.php 2 years ago get_started.php 1 year ago import_wp_statistics.php 4 years ago info.php 1 year ago info_bug_report.php 2 years ago info_help.php 1 year ago info_high_traffic.php 2 years ago info_matomo_desc.php 1 year ago info_multisite.php 2 years ago info_newsletter.php 4 years ago info_shared.php 1 year ago marketplace.php 1 year ago marketplace_setup_wizard.php 1 year ago measurable_settings.php 2 years ago privacy_gdpr.php 4 years ago scheduled_tasks_failures.php 2 years ago settings.php 4 years ago settings_errors.php 4 years ago summary.php 4 years ago systemreport.php 1 year ago tracking.php 1 year ago update_notice_clear_cache.php 5 years ago whats-new-notifications.php 1 year ago
tracking.php
827 lines
1 <?php
2 /**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 * @package matomo
8 * Code Based on
9 * @author Andr&eacute; Br&auml;kling
10 * https://github.com/braekling/WP-Matomo
11 *
12 */
13 /**
14 * phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
15 */
16 use WpMatomo\Admin\TrackingSettings;
17 use WpMatomo\Paths;
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22 /** @var \WpMatomo\Settings $settings */
23 /** @var bool $was_updated */
24 /** @var array $matomo_default_tracking_code */
25 /** @var array $containers */
26 /** @var array $track_modes */
27 /** @var array $matomo_currencies */
28 /** @var string[] $settings_errors */
29 /** @var array $cookie_consent_modes */
30 /** @var string $matomo_exclusion_settings_url */
31 /** @var array $matomo_track_mode_descriptions $matomo_form */
32
33 $matomo_form = new \WpMatomo\Admin\TrackingSettings\Forms( $settings );
34 $matomo_paths = new Paths();
35 ?>
36
37 <?php
38 if ( $was_updated ) {
39 include 'update_notice_clear_cache.php';
40 }
41 if ( count( $settings_errors ) ) {
42 include 'settings_errors.php';
43 }
44
45 ?>
46 <?php
47 $track_mode = $settings->get_global_option( 'track_mode' );
48 $matomo_is_not_tracking = TrackingSettings::TRACK_MODE_DISABLED === $track_mode;
49
50 $matomo_is_not_generated_tracking = $matomo_is_not_tracking || $settings->get_global_option( 'track_mode' ) === TrackingSettings::TRACK_MODE_MANUALLY;
51 $matomo_full_generated_tracking_group = 'matomo-track-option matomo-track-option-default ';
52
53 $matomo_manually_network = '';
54 if ( $settings->is_network_enabled() ) {
55 $matomo_manually_network = ' ' . sprintf( esc_html__( 'You can use these variables: %1$s. %2$sLearn more%3$s', 'matomo' ), '{MATOMO_IDSITE}, {MATOMO_API_ENDPOINT}, {MATOMO_JS_ENDPOINT}', '<a href="https://matomo.org/faq/wordpress/how-can-i-configure-the-tracking-code-manually-when-i-have-wordpress-network-enabled-in-multisite-mode/" target="_blank" rel="noreferrer noopener">', '</a>' );
56 }
57
58 $matomo_submit_button = '<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . esc_attr__( 'Save Changes', 'matomo' ) . '" /></p>';
59 ?>
60 <style>
61 .post-types {
62 display: flex;
63 flex-direction: row;
64 flex-wrap: wrap;
65 align-items: center;
66 }
67
68 .post-types > * {
69 margin-right: 8px;
70 }
71
72 .collapsible-settings > h2 {
73 cursor: pointer;
74 }
75
76 .collapsible-settings:not(.expanded) > *:not(h2) {
77 display: none;
78 }
79
80 .collapsible-settings > h2::before {
81 display: inline-block;
82 content: "";
83 margin-right: 4px;
84 margin-left: 4px;
85 }
86
87 .collapsible-settings.expanded > h2::before {
88 transform: rotate(90deg);
89 margin-right: 6px;
90 }
91
92 #tracking-settings .widefat td p.description {
93 margin-bottom: 0;
94 }
95
96 label[for="tagmanger_container_ids"] {
97 display: block;
98 margin-bottom: 1em;
99 }
100
101 #matomo-tagmanager-container-select {
102 display: none;
103 }
104
105 #tracking-settings[data-track-mode="tagmanager"] #matomo-tagmanager-container-select {
106 display: table-row;
107 }
108
109 #tagmanager-read-more-link {
110 margin-left: 1.5em;
111 }
112
113 #tracking-settings .inactive-notice {
114 display: none;
115 text-transform: uppercase;
116 font-weight: 400;
117 font-size: 10px;
118 margin-bottom: 2px;
119 }
120
121 #tracking-settings:not([data-track-mode="manually"]) #manual-tracking-settings > h2 {
122 color: #888;
123 }
124
125 #tracking-settings:not([data-track-mode="default"]) #auto-tracking-settings > h2 {
126 color: #888;
127 }
128
129 #tracking-settings:not([data-track-mode="manually"]) #manual-tracking-settings .inactive-notice {
130 display: inline-block;
131 }
132
133 #tracking-settings:not([data-track-mode="default"]) #auto-tracking-settings .inactive-notice {
134 display: inline-block;
135 }
136
137 #tracking-settings:not([data-track-mode="tagmanager"]) .tagmanager-container-select {
138 display: none;
139 }
140 </style>
141 <script>
142 window.jQuery(document).ready(function ($) {
143 // even spacing between post types
144 function setPostTypeSpacing() {
145 var postTypes = $('.post-types > div:visible');
146 if (postTypes.length) {
147 var postLengths = postTypes.toArray().map(function (e) {
148 return $(e).width();
149 });
150
151 var maxPostLength = Math.max.apply(null, postLengths);
152 postTypes.each(function () {
153 $(this).width(maxPostLength);
154 });
155 }
156 }
157
158 $('#tracking-settings').on('click', '.collapsible-settings h2', function (e) {
159 $(e.target).closest('.collapsible-settings').toggleClass('expanded');
160 setPostTypeSpacing();
161 });
162
163 function onTrackModeChange() {
164 var currentTrackMode = $('input[name="matomo[track_mode]"]:checked').val();
165
166 // set the current track mode as an attribute on the <form> for css
167 $(this)
168 .closest('form')
169 .attr('data-track-mode', currentTrackMode);
170
171 // mark setting sections that do not apply to the currently selected track mode
172 // as "inactive"
173 $('h2[data-inactive-title]')
174 .removeAttr('title')
175 .each(function () {
176 if (currentTrackMode !== $(this).closest('[data-settings-for]').attr('data-settings-for')) {
177 $(this).attr('title', $(this).attr('data-inactive-title'));
178 }
179 });
180
181 // if a settings section for the currently selected track mode, auto expand it, and
182 // auto collapse other sections
183 $('[data-settings-for]')
184 .removeClass('expanded')
185 .each(function () {
186 $(this).toggleClass('expanded', $(this).attr('data-settings-for') === currentTrackMode);
187 });
188 }
189
190 $('#track_mode').on('change', onTrackModeChange);
191 onTrackModeChange();
192 });
193 </script>
194 <form id="tracking-settings" method="post" data-track-mode="<?php echo esc_attr( $track_mode ); ?>" action="#">
195 <?php wp_nonce_field( TrackingSettings::NONCE_NAME ); ?>
196 <p>
197 <?php esc_html_e( 'Here you can configure visit tracking to your liking. Alternatively, you can simply enable tracking, and just rely on the default settings.', 'matomo' ); ?>
198 </p>
199
200 <table class="matomo-tracking-form widefat">
201 <tbody>
202 <?php
203 $matomo_form->show_radio(
204 'track_mode',
205 esc_html__( 'Tracking mode', 'matomo' ),
206 $track_modes,
207 $matomo_track_mode_descriptions,
208 null,
209 false,
210 'track_mode'
211 );
212 ?>
213 </tbody>
214 </table>
215
216 <?php
217 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
218 echo $matomo_submit_button;
219 ?>
220
221 <hr/>
222
223 <div id="general-settings" class="collapsible-settings">
224 <h2><?php esc_html_e( 'General Tracking Settings', 'matomo' ); ?></h2>
225 <p><?php esc_html_e( 'These settings apply to all tracking modes (unless otherwise stated).', 'matomo' ); ?></p>
226
227 <h4><?php esc_html_e( 'Ecommerce Tracking', 'matomo' ); ?></h4>
228 <table class="matomo-tracking-form widefat">
229 <tbody>
230 <?php
231 $matomo_form->show_checkbox(
232 'track_ecommerce',
233 esc_html__( 'Enable ecommerce', 'matomo' ),
234 esc_html__( 'Enable to track Ecommerce orders, abandoned carts and product views for WooCommerce, Easy Digital Downloads, MemberPress, and more. Disabling this feature will stop tracking ecommerce data and remove Ecommerce reports from the Matomo display.', 'matomo' ),
235 false,
236 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
237 );
238
239 $matomo_form->show_select(
240 \WpMatomo\Settings::SITE_CURRENCY,
241 esc_html__( 'Currency', 'matomo' ),
242 $matomo_currencies,
243 esc_html__( 'Choose the currency which will be used in reports. This currency will be used if you have an ecommerce store or if you are using the Matomo goals feature and assign a monetary value to a goal.', 'matomo' ),
244 ''
245 );
246
247 $matomo_server_side_visitor_id_desc =
248 esc_html__( 'When enabled Matomo will force the use of a temporary server side generated ID if a Visitor ID cookie is not found. This allows ecommerce events to be properly attributed to visits when cookies are blocked or cookieless tracking is used. The visitor ID will only be valid for the duration of a single visit.', 'matomo' )
249 . '<br/><br/>'
250 . esc_html__( 'Note that using this setting may not be allowed by your local privacy regulations, as some regulations require consent to be given before using a visitor ID and/or tracking ecommerce events.', 'matomo' )
251 . '<br/><br/>'
252 . esc_html__( 'Also note: this setting will not work if you are using using Varnish or another caching mechanism as it starts the WooCommerce session early for visitors that do not have the visitor ID cookie.', 'matomo' );
253
254 $matomo_form->show_checkbox(
255 \WpMatomo\Settings::USE_SESSION_VISITOR_ID_OPTION_NAME,
256 esc_html__( 'Use server generated Visitor ID', 'matomo' ),
257 $matomo_server_side_visitor_id_desc,
258 false,
259 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager',
260 false,
261 '',
262 false
263 );
264 ?>
265 </tbody>
266 </table>
267
268 <h4><?php esc_html_e( 'Other Tracking', 'matomo' ); ?></h4>
269 <table class="matomo-tracking-form widefat">
270 <tbody>
271 <?php
272 $matomo_form->show_checkbox(
273 'track_admin',
274 esc_html__( 'Track admin pages', 'matomo' ),
275 sprintf(
276 esc_html__( 'Enable to track users on WordPress admin pages (%1$sremember to configure the tracking filter appropriately%2$s).', 'matomo' ),
277 '<a href="' . esc_attr( $matomo_exclusion_settings_url ) . '" />',
278 '</a>'
279 ),
280 false,
281 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
282 );
283
284 $matomo_form->show_select(
285 'track_user_id',
286 __( 'Track WordPress User ID', 'matomo' ),
287 [
288 'disabled' => esc_html__( 'Disabled', 'matomo' ),
289 'uid' => esc_html__( 'WP User ID', 'matomo' ),
290 'email' => esc_html__( 'Email Address', 'matomo' ),
291 'username' => esc_html__( 'Username', 'matomo' ),
292 'displayname' => esc_html__( 'Display Name (Not Recommended!)', 'matomo' ),
293 ],
294 __( 'When a user is logged in to WordPress, track their &quot;User ID&quot;. You can select which field from the User\'s profile is tracked as the &quot;User ID&quot;.', 'matomo' ),
295 '',
296 false,
297 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
298 );
299
300 $matomo_form->show_checkbox(
301 'track_search',
302 esc_html__( 'Track search', 'matomo' ),
303 esc_html__( 'Enable Matomo\'s advanced Site Search Analytics feature.', 'matomo' ) . ' ' .
304 sprintf(
305 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
306 '<a href="https://matomo.org/faq/reports/tracking-site-search-keywords/#track-site-search-using-the-tracking-api-advanced-users-only" rel="noreferrer noopener" target="_BLANK">',
307 '</a>'
308 ),
309 false,
310 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
311 );
312
313 $matomo_form->show_checkbox(
314 'track_404',
315 esc_html__( 'Track 404', 'matomo' ),
316 esc_html__( 'Matomo can automatically add a 404-category to track 404-page-visits.', 'matomo' ) .
317 ' ' . sprintf(
318 esc_html__( 'See %1$sMatomo FAQ%2$s.', 'matomo' ),
319 '<a href="https://matomo.org/faq/how-to/faq_60/" rel="noreferrer noopener" target="_BLANK">',
320 '</a>'
321 ),
322 false,
323 $matomo_full_generated_tracking_group . ' matomo-track-option-manually'
324 );
325
326 $matomo_form->show_checkbox(
327 'track_feed',
328 esc_html__( 'Track RSS feeds', 'matomo' ),
329 esc_html__( 'Enable to use a tracking pixel to track visitors that view posts in RSS feed viewers.', 'matomo' ),
330 false,
331 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
332 );
333
334 $matomo_form->show_checkbox(
335 'track_feed_addcampaign',
336 esc_html__( 'Track RSS feed links as campaign', 'matomo' ),
337 esc_html__( 'This will add Matomo campaign parameters to RSS feed links.', 'matomo' ) . ' ' . sprintf( esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ), '<a href="https://matomo.org/docs/tracking-campaigns/" rel="noreferrer noopener" target="_BLANK">', '</a>' ),
338 false,
339 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager',
340 false,
341 'jQuery(\'tr.matomo-feed_campaign-option\').toggle(\'hidden\');'
342 );
343
344 $matomo_form->show_input(
345 'track_feed_campaign',
346 esc_html__( 'RSS feed campaign name', 'matomo' ),
347 esc_html__( 'The campaign name to use if RSS feed links are tracked as a campaign.', 'matomo' ),
348 true,
349 $matomo_full_generated_tracking_group . ' matomo-feed_campaign-option matomo-track-option-tagmanager'
350 );
351 ?>
352 </tbody>
353 </table>
354
355 <h4><?php esc_html_e( 'Create Matomo annotations on', 'matomo' ); ?></h4>
356 <table class="matomo-tracking-form widefat">
357 <tbody>
358 <?php
359 echo '<tr class="' . esc_attr( $matomo_full_generated_tracking_group ) . ' matomo-track-option-manually">';
360 echo '<th scope="row"><label for="add_post_annotations">' . esc_html__( 'On new post of type', 'matomo' ) . ':</label></th><td>';
361 echo '<div class="post-types">';
362 $matomo_filter = $settings->get_global_option( 'add_post_annotations' );
363 foreach ( get_post_types( [], 'objects' ) as $object_post_type ) {
364 echo '<div><input type="checkbox" ' . ( isset( $matomo_filter [ $object_post_type->name ] ) && $matomo_filter [ $object_post_type->name ] ? 'checked="checked" ' : '' ) . 'value="1" name="matomo[add_post_annotations][' . esc_attr( $object_post_type->name ) . ']" /> <span>' . esc_html( $object_post_type->label ) . '</span></div>';
365 }
366 echo '</div>';
367 echo '<p class="description" id="add_post_annotations-desc">' . sprintf( esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ), '<a href="https://matomo.org/docs/annotations/" rel="noreferrer noopener" target="_BLANK">', '</a>' ) . '</p></td></tr>';
368 ?>
369 </tbody>
370 </table>
371
372 <h4><?php esc_html_e( 'Advanced', 'matomo' ); ?></h4>
373 <table class="matomo-tracking-form widefat">
374 <tbody>
375 <?php
376 $matomo_form->show_checkbox(
377 'track_noscript',
378 __( 'Add &lt;noscript&gt; to track visitors who disable JavaScript', 'matomo' ),
379 __( 'Adds the &lt;noscript&gt; code to your footer. This code is either generated automatically or defined by you, based on which tracking mode you choose use. This can be useful if you have a lot of visitors that have JavaScript disabled.', 'matomo' )
380 . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Tag Manager tracking mode.', 'matomo' ) . '</em>',
381 false,
382 'matomo-track-option matomo-track-option-default matomo-track-option-manually'
383 );
384 ?>
385 </tbody>
386 </table>
387 </div>
388
389 <hr/>
390
391 <div id="auto-tracking-settings" class="collapsible-settings" data-settings-for="default">
392 <h2 data-inactive-title="<?php esc_attr_e( 'Note: these settings will only apply if the Auto tracking mode is active.', 'matomo' ); ?>">
393 <?php esc_html_e( 'Settings for Auto Tracking mode', 'matomo' ); ?>
394 <span class="inactive-notice">(<?php esc_html_e( 'Inactive', 'matomo' ); ?>)</span>
395 </h2>
396 <p><?php esc_html_e( 'The Auto tracking mode automatically generates and embeds the Matomo tracking JavaScript based on the settings below. Pick and choose what you\'d like to track, and Matomo for WordPress will set everything else up for you.', 'matomo' ); ?></p>
397 <p id="showGeneratedTrackingCode"><a href="#"><?php esc_html_e( 'Show generated tracking code', 'matomo' ); ?></a></p>
398 <p id="hideGeneratedTrackingCode" style="display:none;"><a href="#"><?php esc_html_e( 'Hide generated tracking code', 'matomo' ); ?></a></p>
399 <table class="matomo-tracking-form widefat" id="generatedTrackingCode" style="display:none;margin-bottom:1em;">
400 <?php
401 $matomo_form->show_textarea(
402 'generated_tracking_code',
403 esc_html__( 'Tracking code', 'matomo' ),
404 15,
405 sprintf(
406 esc_html__( 'This is a preview of the tracking code generated based on the configuration below. You don\'t need to do anything with it and this is purely for your information. The tracking code is a piece of code that will be automatically embedded into your site and send information about your visitors to Matomo. Have a look at the system report to get a list of all available JS tracker and tracking API endpoints. Our plugin will automatically embed this code into your website. %s', 'matomo' ),
407 $matomo_manually_network
408 ),
409 false,
410 '',
411 false,
412 '',
413 true,
414 false,
415 true
416 );
417
418 $matomo_form->show_textarea(
419 'generated_noscript_code',
420 esc_html__( '<noscript> code', 'matomo' ),
421 2,
422 __( 'This is a preview of your &lt;noscript&gt; code which is part of your tracking code. This code will only be embedded into your website if the noscript feature is enabled.', 'matomo' ),
423 false,
424 '',
425 false,
426 '',
427 true,
428 false,
429 true
430 );
431 ?>
432 </table>
433 <script>
434 jQuery('#showGeneratedTrackingCode,#hideGeneratedTrackingCode').on('click', 'a', function (e) {
435 e.preventDefault();
436 e.stopPropagation();
437 jQuery('#generatedTrackingCode,#showGeneratedTrackingCode,#hideGeneratedTrackingCode').toggle();
438 });
439 </script>
440
441 <h4><?php esc_html_e( 'Privacy', 'matomo' ); ?></h4>
442 <table class="matomo-tracking-form widefat">
443 <tbody>
444 <?php
445 $matomo_form->show_checkbox(
446 'disable_cookies',
447 esc_html__( 'Disable cookies', 'matomo' ),
448 esc_html__( 'Disable the use of tracking cookies entirely. Using this setting may make it easier to achieve privacy compliance, but Matomo will not be able to recognize returning visitors as effectively.', 'matomo' ),
449 false,
450 $matomo_full_generated_tracking_group
451 );
452
453 $matomo_form->show_checkbox(
454 'limit_cookies',
455 esc_html__( 'Limit cookie lifetime', 'matomo' ),
456 esc_html__( 'If necessary, you can limit the cookie lifetime to avoid tracking your users over a longer period.', 'matomo' ),
457 false,
458 $matomo_full_generated_tracking_group,
459 false,
460 'jQuery(\'tr.matomo-cookielifetime-option\').toggleClass(\'hidden\');'
461 );
462
463 $matomo_form->show_input(
464 'limit_cookies_visitor',
465 esc_html__( 'Visitor timeout (seconds)', 'matomo' ),
466 false,
467 ! $settings->get_global_option( 'limit_cookies' ),
468 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
469 );
470
471 $matomo_form->show_input(
472 'limit_cookies_session',
473 esc_html__( 'Session timeout (seconds)', 'matomo' ),
474 false,
475 ! $settings->get_global_option( 'limit_cookies' ),
476 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
477 );
478
479 $matomo_form->show_input(
480 'limit_cookies_referral',
481 esc_html__( 'Referral timeout (seconds)', 'matomo' ),
482 false,
483 ! $settings->get_global_option( 'limit_cookies' ),
484 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
485 );
486 ?>
487 </tbody>
488 </table>
489
490 <h4><?php esc_html_e( 'Subdomains', 'matomo' ); ?></h4>
491 <table class="matomo-tracking-form widefat">
492 <tbody>
493 <?php
494 $matomo_form->show_checkbox(
495 'track_across',
496 esc_html__( 'Track subdomains in the same website', 'matomo' ),
497 esc_html__( 'Track visitors across subdomains by adding a *.-prefix to the cookie domain.', 'matomo' ) . ' ' .
498 sprintf(
499 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
500 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#tracking-subdomains-in-the-same-website" rel="noreferrer noopener" target="_BLANK">',
501 '</a>'
502 ),
503 false,
504 $matomo_full_generated_tracking_group
505 );
506
507 $matomo_form->show_checkbox(
508 'track_across_alias',
509 esc_html__( 'Do not count subdomains as outlink', 'matomo' ),
510 esc_html__( 'Treats all subdomains as part of the same website, by adding a *.-prefix to the tracked domain.', 'matomo' ) . ' ' .
511 sprintf(
512 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
513 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#outlink-tracking-exclusions" rel="noreferrer noopener" target="_BLANK">',
514 '</a>'
515 ),
516 false,
517 $matomo_full_generated_tracking_group
518 );
519
520 $matomo_form->show_checkbox(
521 'track_crossdomain_linking',
522 esc_html__( 'Enable cross domain linking', 'matomo' ),
523 esc_html__( 'When enabled, it will make sure to use the same visitor ID for the same visitor across several domains. This only works when this feature is enabled because the visitor ID is stored in a cookie and cookies cannot be read when on a different domain. When this feature is enabled, it will append a URL parameter "pk_vid" that contains the visitor ID when a user clicks on a URL that belongs to one of your domains. For this feature to work, you also have to configure which domains should be treated as local in your Matomo website settings.', 'matomo' ),
524 false,
525 $matomo_full_generated_tracking_group
526 );
527 ?>
528 </tbody>
529 </table>
530
531 <h4><?php esc_html_e( 'Link Tracking', 'matomo' ); ?></h4>
532 <table class="matomo-tracking-form widefat">
533 <tbody>
534 <?php
535 $matomo_form->show_input(
536 'add_download_extensions',
537 esc_html__( 'Add new file types for download tracking', 'matomo' ),
538 sprintf(
539 esc_html__( 'Matomo automatically detects file downloads if the extension of the file is in %1$sthis list%2$s. If you\'d like to track other file types as downloads, you can add their extensions here, divided by a vertical bar (&#124;).', 'matomo' ),
540 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#tracking-file-downloads" rel="noreferrer noopener" target="_BLANK">',
541 '</a>'
542 ),
543 false,
544 $matomo_full_generated_tracking_group
545 );
546
547 $matomo_form->show_input(
548 'set_download_extensions',
549 esc_html__( 'Define all file types for download tracking', 'matomo' ),
550 esc_html__( 'Replace Matomo\'s default file extensions for download tracking, divided by a vertical bar (&#124;). Leave blank to keep Matomo\'s default settings (recommended).', 'matomo' ) . ' ' .
551 sprintf(
552 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
553 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#file-extensions-for-tracking-downloads" target="_BLANK">',
554 '</a>'
555 ),
556 false,
557 $matomo_full_generated_tracking_group
558 );
559
560 $matomo_form->show_input(
561 'set_download_classes',
562 esc_html__( 'Set CSS classes to be treated as downloads', 'matomo' ),
563 esc_html__( 'Set the CSS classes of links that, when clicked, should be tracked as downloads (in addition to \'piwik_download\'). Enter the list of CSS classes divided by a vertical bar (&#124;). Leave blank to keep Matomo\'s default settings.', 'matomo' ) . ' ' .
564 sprintf(
565 esc_html__( 'See %1$sMatomo JavaScript Tracking Client reference%2$s.', 'matomo' ),
566 '<a href="https://developer.matomo.org/api-reference/tracking-javascript" target="_BLANK">',
567 '</a>'
568 ),
569 false,
570 $matomo_full_generated_tracking_group
571 );
572
573 $matomo_form->show_input(
574 'set_link_classes',
575 esc_html__( 'Set CSS classes to be treated as outlinks', 'matomo' ),
576 esc_html__( 'Set CSS classes of links that, when clicked, should be treated as outlinks (in addition to piwik_link), divided by a vertical bar (&#124;). Leave blank to keep Matomo\'s default settings.', 'matomo' ) . ' ' .
577 sprintf(
578 esc_html__( 'See %1$sMatomo JavaScript Tracking Client reference%2$s.', 'matomo' ),
579 '<a href="https://developer.matomo.org/api-reference/tracking-javascript" target="_BLANK">',
580 '</a>'
581 ),
582 false,
583 $matomo_full_generated_tracking_group
584 );
585 ?>
586 </tbody>
587 </table>
588
589 <h4><?php esc_html_e( 'Other Tracking', 'matomo' ); ?></h4>
590 <table class="matomo-tracking-form widefat">
591 <tbody>
592 <?php
593 $matomo_form->show_checkbox(
594 'track_jserrors',
595 esc_html__( 'Track JS errors', 'matomo' ),
596 esc_html__( 'Enable to track JavaScript errors that occur on your website as Matomo events.', 'matomo' )
597 . ' ' . sprintf( esc_html__( 'See %1$sMatomo FAQ%2$s.', 'matomo' ), '<a href="https://matomo.org/faq/how-to/how-do-i-enable-basic-javascript-error-tracking-and-reporting-in-matomo-browser-console-error-messages/" rel="noreferrer noopener" target="_BLANK">', '</a>' )
598 . ' ' . sprintf( esc_html__( 'For more advanced reporting of crashes, check out our %1$sCrash Analytics premium feature%2$s.', 'matomo' ), '<a href="https://plugins.matomo.org/CrashAnalytics?wp=1" target="_blank" rel="noreferrer noopener">', '</a>' ),
599 false,
600 $matomo_full_generated_tracking_group
601 );
602
603 $matomo_form->show_select(
604 'track_content',
605 __( 'Enable content tracking', 'matomo' ),
606 [
607 'disabled' => esc_html__( 'Disabled', 'matomo' ),
608 'all' => esc_html__( 'Track all content blocks', 'matomo' ),
609 'visible' => esc_html__( 'Track only visible content blocks', 'matomo' ),
610 ],
611 __( 'Content tracking allows you to track interactions with pieces of content within your website.', 'matomo' ) . ' ' . sprintf( esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ), '<a href="https://developer.matomo.org/guides/content-tracking" rel="noreferrer noopener" target="_BLANK">', '</a>' ),
612 '',
613 false,
614 $matomo_full_generated_tracking_group
615 );
616
617 $matomo_form->show_input(
618 'track_heartbeat',
619 esc_html__( 'Enable heartbeat timer (enable with care)', 'matomo' ),
620 __( 'Enable a heartbeat timer to get more accurate visit lengths by sending periodic HTTP ping requests while a visitor is viewing your website. Enter the time between the pings in seconds (Matomo default: 15) to enable or 0 to disable this feature. <strong>Note:</strong> This will multiply the HTTP requests your website receives, which may cause performance issues based on your infrastructure and website traffic. Enable this setting with care.', 'matomo' ),
621 false,
622 $matomo_full_generated_tracking_group
623 );
624 ?>
625 </tbody>
626 </table>
627
628 <h4><?php esc_html_e( 'Advanced', 'matomo' ); ?></h4>
629 <table class="matomo-tracking-form widefat">
630 <tbody>
631 <?php
632 $matomo_form->show_checkbox(
633 'force_post',
634 esc_html__( 'Force POST requests', 'matomo' ),
635 esc_html__( 'When enabled, Matomo will always use POST requests. This can be helpful should you experience HTTP 414 URI too long errors in your tracking code.', 'matomo' ),
636 false,
637 $matomo_full_generated_tracking_group
638 );
639
640 $matomo_form->show_select(
641 'cookie_consent',
642 esc_html__( 'Custom consent screen', 'matomo' ),
643 $cookie_consent_modes,
644 sprintf(
645 esc_html__( 'Activates a specific Matomo consent mode. Only configure a consent mode if you are implementing a consent screen yourself. This requires a custom consent implementation. For more information please read this %1$sFAQ%2$s (this option will take care of step 1 for you). By default no consent mode is applied.', 'matomo' ),
646 '<a href="https://developer.matomo.org/guides/tracking-consent" rel="noreferrer noopener" target="_blank">',
647 '</a>'
648 ),
649 '',
650 false,
651 $matomo_full_generated_tracking_group
652 );
653
654 $matomo_form->show_select(
655 'track_api_endpoint',
656 __( 'Endpoint for HTTP Tracking API', 'matomo' ),
657 [
658 'default' => esc_html__( 'Default', 'matomo' ),
659 'restapi' => esc_html__( 'Through WordPress Rest API', 'matomo' ),
660 ],
661 sprintf( __( 'By default the HTTP Tracking API points to your Matomo plugin directory "%1$s". You can choose to use the WP Rest API (%2$s) instead for example to hide matomo.php or if the other URL doesn\'t work for you. Note: If the "Tag Manager" tracking mode is selected, then this URL will only be used in feed tracking.', 'matomo' ), esc_html( $matomo_paths->get_tracker_api_url_in_matomo_dir() ), esc_html( $matomo_paths->get_tracker_api_rest_api_endpoint() ) ),
662 '',
663 false,
664 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
665 );
666
667 $matomo_form->show_select(
668 'track_js_endpoint',
669 __( 'Endpoint for JavaScript tracker', 'matomo' ),
670 [
671 'default' => esc_html__( 'Default', 'matomo' ),
672 'restapi' => esc_html__( 'Through WordPress Rest API (slower)', 'matomo' ),
673 'plugin' => esc_html__( 'Plugin (an alternative JS file if the default is blocked by the webserver)', 'matomo' ),
674 ],
675 sprintf( __( 'By default the JS tracking code will be loaded from "%1$s". You can choose to serve the JS file through the WP Rest API (%2$s) for example to hide matomo.js. Please note that this means every request to the JavaScript file will launch WordPress PHP and therefore will be slower compared to your webserver serving the JS file directly. Using the "Plugin" method will cause issues with our paid Heatmap and Session Recording, Form Analytics, and Media Analytics plugin.', 'matomo' ), esc_html( $matomo_paths->get_js_tracker_url_in_matomo_dir() ), esc_html( $matomo_paths->get_js_tracker_rest_api_endpoint() ) ),
676 '',
677 false,
678 $matomo_full_generated_tracking_group
679 );
680 ?>
681 </tbody>
682 </table>
683 </div>
684
685 <hr/>
686
687 <div id="manual-tracking-settings" class="collapsible-settings" data-settings-for="manually">
688 <h2 data-inactive-title="<?php esc_attr_e( 'Note: these settings will only apply if the Manual tracking mode is active.', 'matomo' ); ?>">
689 <?php esc_html_e( 'Settings for Manual Tracking mode', 'matomo' ); ?>
690 <span class="inactive-notice">(<?php esc_html_e( 'Inactive', 'matomo' ); ?>)</span>
691 </h2>
692 <p><?php esc_html_e( 'With the Manual tracking mode, you can write the JavaScript tracking code yourself, customizing it any way you need to. Matomo for WordPress will then embed this script into your website\'s HTML.', 'matomo' ); ?></p>
693 <table class="matomo-tracking-form widefat">
694 <tbody>
695 <?php
696 $matomo_form->show_textarea(
697 'tracking_code',
698 esc_html__( 'Tracking code', 'matomo' ),
699 15,
700 sprintf(
701 esc_html__( 'Enter your tracking code here. If you need a starting point, you can use the Auto tracking mode settings and view the generated code in the above section. Have a look at the system report to get a list of all available JS tracker and tracking API endpoints. Note: all you need to do is define the code here. You don\'t need to embed it into your website, our plugin does this automatically. %s', 'matomo' ),
702 $matomo_manually_network
703 ),
704 false,
705 'matomo-track-option matomo-track-option-default matomo-track-option-tagmanager matomo-track-option-manually',
706 ! $settings->is_network_enabled(),
707 '',
708 false,
709 false
710 );
711
712 $matomo_form->show_textarea(
713 'noscript_code',
714 esc_html__( 'Noscript code', 'matomo' ),
715 2,
716 __( 'Enter your custom &lt;noscript&gt; code here. This will only show if the noscript feature is enabled.', 'matomo' ),
717 false,
718 'matomo-track-option matomo-track-option-default matomo-track-option-manually',
719 true,
720 '',
721 false,
722 false
723 );
724 ?>
725 </tbody>
726 </table>
727 </div>
728
729 <hr/>
730
731 <div id="html-tag-settings" class="collapsible-settings">
732 <h2><?php esc_html_e( '<script> Tag Settings', 'matomo' ); ?></h2>
733 <p><?php esc_html_e( 'These options are available for most tracking modes and control exactly how Matomo for WordPress embeds <script> elements into your pages. Most users will not need to change these settings.', 'matomo' ); ?></p>
734 <table class="matomo-tracking-form widefat">
735 <tbody>
736 <?php
737 $matomo_form->show_select(
738 'force_protocol',
739 __( 'Force Matomo to use a specific protocol', 'matomo' ),
740 [
741 'disabled' => esc_html__( 'Disabled (default)', 'matomo' ),
742 'https' => esc_html__( 'https (SSL)', 'matomo' ),
743 ],
744 __( 'Choose if you want to force Matomo to use HTTP or HTTPS.', 'matomo' )
745 . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Manual tracking mode.', 'matomo' ) . '</em>',
746 '',
747 false,
748 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
749 );
750 $matomo_form->show_select(
751 'track_codeposition',
752 __( 'JavaScript code position', 'matomo' ),
753 [
754 'footer' => esc_html__( 'Footer', 'matomo' ),
755 'header' => esc_html__( 'Header', 'matomo' ),
756 ],
757 __( 'Choose whether the JavaScript code is added to the footer or the header.', 'matomo' ),
758 '',
759 false,
760 'matomo-track-option matomo-track-option-default matomo-track-option-tagmanager matomo-track-option-manually'
761 );
762
763 $matomo_form->show_checkbox(
764 'track_datacfasync',
765 esc_html__( 'Add data-cfasync=false', 'matomo' ),
766 esc_html__( 'Adds data-cfasync=false to the script tag, e.g., to ask Rocket Loader to ignore the script.', 'matomo' ) . ' ' .
767 sprintf(
768 esc_html__( 'See %1$sCloudFlare Knowledge Base%2$s.', 'matomo' ),
769 '<a href="https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-my-script-s-in-Automatic-Mode-" rel="noreferrer noopener" target="_BLANK">',
770 '</a>'
771 ) . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Manual tracking mode.', 'matomo' ) . '</em>',
772 false,
773 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
774 );
775 ?>
776 </tbody>
777 </table>
778 </div>
779
780 <hr/>
781
782 <div id="developer-settings" class="collapsible-settings">
783 <h2><?php esc_html_e( 'Developer Settings', 'matomo' ); ?></h2>
784 <p><?php esc_html_e( 'If your tracking code is not working as expected, this setting may help you find out why. When enabled, the tracker debug mode will output diagnostic information in tracking requests. It is recommended to only enable it when/if you need it, and disable it immediately after.', 'matomo' ); ?></p>
785 <table class="matomo-tracking-form widefat">
786 <tbody>
787 <?php
788 $matomo_form->show_select(
789 'tracker_debug',
790 __( 'Tracker Debug Mode', 'matomo' ),
791 [
792 'disabled' => esc_html__( 'Disabled (recommended)', 'matomo' ),
793 'always' => esc_html__( 'Always enabled', 'matomo' ),
794 'on_demand' => esc_html__( 'Enabled on demand', 'matomo' ),
795 ],
796 __( 'For security and privacy reasons you should only enable this setting for as short time of a time as possible.', 'matomo' )
797 . '<br/>'
798 . __( 'If enabling on demand, add \'&debug=1\' to tracker requests to trigger debug output.', 'matomo' ),
799 '',
800 false,
801 $matomo_full_generated_tracking_group . ' matomo-track-option-disabled matomo-track-option-manually matomo-track-option-tagmanager'
802 );
803 ?>
804 </tbody>
805 </table>
806 </div>
807
808 <p>
809 <?php
810 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
811 echo $matomo_submit_button;
812 ?>
813 </p>
814 </form>
815
816 <?php if ( ! $settings->is_network_enabled() ) { // Can't show it for multisite as idsite and url is always different. ?>
817 <div id="matomo_default_tracking_code">
818 <h2><?php esc_html_e( 'JavaScript tracking code', 'matomo' ); ?></h2>
819 <p>
820 <?php echo sprintf( esc_html__( 'Want to embed the tracking code manually into your site or using a different plugin? No problem! Simply copy/paste below tracking code. Want to adjust it? %1$sCheck out our developer documentation.%2$s', 'matomo' ), '<a href="https://developer.matomo.org/guides/tracking-javascript-guide" target="_blank" rel="noreferrer noopener">', '</a>' ); ?>
821 </p>
822 <?php echo '<pre><textarea readonly="readonly">' . esc_html( preg_replace( '/\\n+/', "\n", implode( ";\n", explode( ';', $matomo_default_tracking_code['script'] ) ) ) ) . '</textarea></pre>'; ?>
823 <h3><?php esc_html_e( '<noscript> tracking code', 'matomo' ); ?></h3>
824 <?php echo '<pre><textarea readonly="readonly" class="no_script">' . esc_html( $matomo_default_tracking_code['noscript'] ) . '</textarea></pre>'; ?>
825 </div>
826 <?php } ?>
827