PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
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 7 months ago adblocker-notice.php 7 months ago advanced_settings.php 10 months ago exclusion_settings.php 4 years ago geolocation_settings.php 2 years ago get_started.php 2 months ago import_wp_statistics.php 2 months ago info.php 2 months 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 months ago info_newsletter.php 4 years ago info_shared.php 1 year ago marketplace.php 3 months ago marketplace_setup_wizard.php 3 months ago marketplace_setup_wizard_body.php 3 months ago measurable_settings.php 2 years ago privacy_gdpr.php 4 years ago scheduled_tasks_failures.php 2 years ago settings.php 2 months ago settings_errors.php 4 years ago summary.php 2 months ago systemreport.php 2 months ago tracking.php 4 months ago update_notice_clear_cache.php 5 years ago whats-new-notifications.php 1 year ago
tracking.php
928 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 /** @var bool $matomo_is_advanced_cache_used */
33 /** @var bool $matomo_is_track_script_used_in_wp_config */
34 /** @var bool $matomo_is_track_ai_enabled */
35 /** @var bool $matomo_is_using_litespeed */
36 /** @var bool $matomo_is_using_litespeed_cache */
37 /** @var bool $matomo_is_track_via_esi_enabled */
38 /** @var bool $matomo_is_esi_enabled_in_litespeed */
39 /** @var bool $matomo_is_htaccess_serving_cache_files */
40
41 $matomo_form = new \WpMatomo\Admin\TrackingSettings\Forms( $settings );
42 $matomo_paths = new Paths();
43 ?>
44
45 <?php
46 if ( $was_updated ) {
47 include 'update_notice_clear_cache.php';
48 }
49 if ( count( $settings_errors ) ) {
50 include 'settings_errors.php';
51 }
52
53 ?>
54 <?php
55 $track_mode = $settings->get_global_option( 'track_mode' );
56 $matomo_is_not_tracking = TrackingSettings::TRACK_MODE_DISABLED === $track_mode;
57
58 $matomo_is_not_generated_tracking = $matomo_is_not_tracking || $settings->get_global_option( 'track_mode' ) === TrackingSettings::TRACK_MODE_MANUALLY;
59 $matomo_full_generated_tracking_group = 'matomo-track-option matomo-track-option-default ';
60
61 $matomo_manually_network = '';
62 if ( $settings->is_network_enabled() ) {
63 $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>' );
64 }
65
66 $matomo_submit_button = '<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . esc_attr__( 'Save Changes', 'matomo' ) . '" /></p>';
67 ?>
68 <style>
69 .post-types {
70 display: flex;
71 flex-direction: row;
72 flex-wrap: wrap;
73 align-items: center;
74 }
75
76 .post-types > * {
77 margin-right: 8px;
78 }
79
80 .collapsible-settings > h2 {
81 cursor: pointer;
82 }
83
84 .collapsible-settings:not(.expanded) > *:not(h2) {
85 display: none;
86 }
87
88 .collapsible-settings > h2::before {
89 display: inline-block;
90 content: "";
91 margin-right: 4px;
92 margin-left: 4px;
93 }
94
95 .collapsible-settings.expanded > h2::before {
96 transform: rotate(90deg);
97 margin-right: 6px;
98 }
99
100 #tracking-settings .widefat td p.description {
101 margin-bottom: 0;
102 }
103
104 label[for="tagmanger_container_ids"] {
105 display: block;
106 margin-bottom: 1em;
107 }
108
109 #matomo-tagmanager-container-select {
110 display: none;
111 }
112
113 #tracking-settings[data-track-mode="tagmanager"] #matomo-tagmanager-container-select {
114 display: table-row;
115 }
116
117 #tagmanager-read-more-link {
118 margin-left: 1.5em;
119 }
120
121 #tracking-settings .inactive-notice {
122 display: none;
123 text-transform: uppercase;
124 font-weight: 400;
125 font-size: 10px;
126 margin-bottom: 2px;
127 }
128
129 #tracking-settings:not([data-track-mode="manually"]) #manual-tracking-settings > h2 {
130 color: #888;
131 }
132
133 #tracking-settings:not([data-track-mode="default"]) #auto-tracking-settings > h2 {
134 color: #888;
135 }
136
137 #tracking-settings:not([data-track-mode="manually"]) #manual-tracking-settings .inactive-notice {
138 display: inline-block;
139 }
140
141 #tracking-settings:not([data-track-mode="default"]) #auto-tracking-settings .inactive-notice {
142 display: inline-block;
143 }
144
145 #tracking-settings:not([data-track-mode="tagmanager"]) .tagmanager-container-select {
146 display: none;
147 }
148 </style>
149 <script>
150 window.jQuery(document).ready(function ($) {
151 // even spacing between post types
152 function setPostTypeSpacing() {
153 var postTypes = $('.post-types > div:visible');
154 if (postTypes.length) {
155 var postLengths = postTypes.toArray().map(function (e) {
156 return $(e).width();
157 });
158
159 var maxPostLength = Math.max.apply(null, postLengths);
160 postTypes.each(function () {
161 $(this).width(maxPostLength);
162 });
163 }
164 }
165
166 $('#tracking-settings').on('click', '.collapsible-settings h2', function (e) {
167 $(e.target).closest('.collapsible-settings').toggleClass('expanded');
168 setPostTypeSpacing();
169 });
170
171 function onTrackModeChange() {
172 var currentTrackMode = $('input[name="matomo[track_mode]"]:checked').val();
173
174 // set the current track mode as an attribute on the <form> for css
175 $(this)
176 .closest('form')
177 .attr('data-track-mode', currentTrackMode);
178
179 // mark setting sections that do not apply to the currently selected track mode
180 // as "inactive"
181 $('h2[data-inactive-title]')
182 .removeAttr('title')
183 .each(function () {
184 if (currentTrackMode !== $(this).closest('[data-settings-for]').attr('data-settings-for')) {
185 $(this).attr('title', $(this).attr('data-inactive-title'));
186 }
187 });
188
189 // if a settings section for the currently selected track mode, auto expand it, and
190 // auto collapse other sections
191 $('[data-settings-for]')
192 .removeClass('expanded')
193 .each(function () {
194 $(this).toggleClass('expanded', $(this).attr('data-settings-for') === currentTrackMode);
195 });
196 }
197
198 $('#track_mode').on('change', onTrackModeChange);
199 onTrackModeChange();
200 });
201 </script>
202 <form id="tracking-settings" method="post" data-track-mode="<?php echo esc_attr( $track_mode ); ?>" action="#">
203 <?php wp_nonce_field( TrackingSettings::NONCE_NAME ); ?>
204 <p>
205 <?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' ); ?>
206 </p>
207
208 <table class="matomo-tracking-form widefat">
209 <tbody>
210 <?php
211 $matomo_form->show_radio(
212 'track_mode',
213 esc_html__( 'Tracking mode', 'matomo' ),
214 $track_modes,
215 $matomo_track_mode_descriptions,
216 null,
217 false,
218 'track_mode'
219 );
220 ?>
221 </tbody>
222 </table>
223
224 <?php
225 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
226 echo $matomo_submit_button;
227 ?>
228
229 <hr/>
230
231 <div id="general-settings" class="collapsible-settings">
232 <h2><?php esc_html_e( 'General Tracking Settings', 'matomo' ); ?></h2>
233 <p><?php esc_html_e( 'These settings apply to all tracking modes (unless otherwise stated).', 'matomo' ); ?></p>
234
235 <h4><?php esc_html_e( 'Ecommerce Tracking', 'matomo' ); ?></h4>
236 <table class="matomo-tracking-form widefat">
237 <tbody>
238 <?php
239 $matomo_form->show_checkbox(
240 'track_ecommerce',
241 esc_html__( 'Enable ecommerce', 'matomo' ),
242 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' ),
243 false,
244 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
245 );
246
247 $matomo_form->show_select(
248 \WpMatomo\Settings::SITE_CURRENCY,
249 esc_html__( 'Currency', 'matomo' ),
250 $matomo_currencies,
251 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' ),
252 ''
253 );
254
255 $matomo_server_side_visitor_id_desc =
256 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' )
257 . '<br/><br/>'
258 . 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' )
259 . '<br/><br/>'
260 . 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' );
261
262 $matomo_form->show_checkbox(
263 \WpMatomo\Settings::USE_SESSION_VISITOR_ID_OPTION_NAME,
264 esc_html__( 'Use server generated Visitor ID', 'matomo' ),
265 $matomo_server_side_visitor_id_desc,
266 false,
267 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager',
268 false,
269 '',
270 false
271 );
272 ?>
273 </tbody>
274 </table>
275
276 <h4><?php esc_html_e( 'Other Tracking', 'matomo' ); ?></h4>
277 <table class="matomo-tracking-form widefat">
278 <tbody>
279 <?php
280 $matomo_form->show_checkbox(
281 'track_admin',
282 esc_html__( 'Track admin pages', 'matomo' ),
283 sprintf(
284 esc_html__( 'Enable to track users on WordPress admin pages (%1$sremember to configure the tracking filter appropriately%2$s).', 'matomo' ),
285 '<a href="' . esc_attr( $matomo_exclusion_settings_url ) . '" />',
286 '</a>'
287 ),
288 false,
289 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
290 );
291
292 $matomo_form->show_select(
293 'track_user_id',
294 __( 'Track WordPress User ID', 'matomo' ),
295 [
296 'disabled' => esc_html__( 'Disabled', 'matomo' ),
297 'uid' => esc_html__( 'WP User ID', 'matomo' ),
298 'email' => esc_html__( 'Email Address', 'matomo' ),
299 'username' => esc_html__( 'Username', 'matomo' ),
300 'displayname' => esc_html__( 'Display Name (Not Recommended!)', 'matomo' ),
301 ],
302 __( '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' ),
303 '',
304 false,
305 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
306 );
307
308 $matomo_form->show_checkbox(
309 'track_search',
310 esc_html__( 'Track search', 'matomo' ),
311 esc_html__( 'Enable Matomo\'s advanced Site Search Analytics feature.', 'matomo' ) . ' ' .
312 sprintf(
313 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
314 '<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">',
315 '</a>'
316 ),
317 false,
318 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
319 );
320
321 $matomo_form->show_checkbox(
322 'track_404',
323 esc_html__( 'Track 404', 'matomo' ),
324 esc_html__( 'Matomo can automatically add a 404-category to track 404-page-visits.', 'matomo' ) .
325 ' ' . sprintf(
326 esc_html__( 'See %1$sMatomo FAQ%2$s.', 'matomo' ),
327 '<a href="https://matomo.org/faq/how-to/faq_60/" rel="noreferrer noopener" target="_BLANK">',
328 '</a>'
329 ),
330 false,
331 $matomo_full_generated_tracking_group . ' matomo-track-option-manually'
332 );
333
334 $matomo_form->show_checkbox(
335 'track_feed',
336 esc_html__( 'Track RSS feeds', 'matomo' ),
337 esc_html__( 'Enable to use a tracking pixel to track visitors that view posts in RSS feed viewers.', 'matomo' ),
338 false,
339 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
340 );
341
342 $matomo_form->show_checkbox(
343 'track_feed_addcampaign',
344 esc_html__( 'Track RSS feed links as campaign', 'matomo' ),
345 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>' ),
346 false,
347 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager',
348 false,
349 'jQuery(\'tr.matomo-feed_campaign-option\').toggle(\'hidden\');'
350 );
351
352 $matomo_form->show_input(
353 'track_feed_campaign',
354 esc_html__( 'RSS feed campaign name', 'matomo' ),
355 esc_html__( 'The campaign name to use if RSS feed links are tracked as a campaign.', 'matomo' ),
356 true,
357 $matomo_full_generated_tracking_group . ' matomo-feed_campaign-option matomo-track-option-tagmanager'
358 );
359
360 $matomo_form->show_checkbox(
361 \WpMatomo\Settings::TRACK_AI_BOTS,
362 esc_html__( 'Track AI Bots', 'matomo' ),
363 esc_html__( 'If enabled, AI bots will trigger page views even if they do not execute JavaScript. These page views can be seen in the special AI Assistants report.', 'matomo' ),
364 false,
365 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager',
366 false,
367 "window.jQuery('.matomo-track-ai-warning,.matomo-track-ai-using-esi').toggle();"
368 );
369
370 if ( $matomo_is_htaccess_serving_cache_files ) {
371 ?>
372 <tr>
373 <td></td>
374 <td>
375 <div class="matomo-inline-notice matomo-warning matomo-track-ai-warning" style="<?php echo $matomo_is_track_ai_enabled ? '' : 'display:none;'; ?>">
376 <p>
377 <strong><?php esc_html_e( 'Warning', 'matomo' ); ?>:</strong>
378 <?php esc_html_e( 'Your caching plugin is using an .htaccess file to serve cached pages directly through your webserver, bypassing PHP. AI bots cannot be tracked for pages served this way. Please consult your caching plugin documentation if you wish to disable this behavior.', 'matomo' ); ?>
379 </p>
380 </div>
381 </td>
382 </tr>
383 <?php
384 } elseif ( $matomo_is_advanced_cache_used && false === $matomo_is_track_script_used_in_wp_config ) {
385 ?>
386 <tr>
387 <td></td>
388 <td>
389 <div class="matomo-inline-notice matomo-warning matomo-track-ai-warning" style="<?php echo $matomo_is_track_ai_enabled ? '' : 'display:none;'; ?>">
390 <p>
391 <strong><?php esc_html_e( 'Warning', 'matomo' ); ?>:</strong>
392 <?php esc_html_e( 'We noticed WordPress\' advanced cache feature is active. This feature will serve your blog pages without ever loading your WordPress plugins. To track AI bots while the advanced cache is active you will need to add the following snippet to your wp-config.php file:', 'matomo' ); ?>
393 </p>
394 <p>
395 <textarea rows="3" readonly="readonly">if ( is_file( ABSPATH . 'wp-content/plugins/matomo/misc/track_ai_bot.php' ) ) {
396 require_once ABSPATH . 'wp-content/plugins/matomo/misc/track_ai_bot.php';
397 }</textarea>
398 </p>
399 <p><?php echo sprintf( esc_html__( 'Make sure to add it immediately before the line that reads %1$srequire_once ABSPATH . \'wp-settings.php\';%2$s.', 'matomo' ), '<code>', '</code>' ); ?></p>
400 </div>
401 </td>
402 </tr>
403 <?php
404 }
405
406 $matomo_form->show_checkbox(
407 \WpMatomo\Settings::TRACK_AI_BOTS_USING_ESI,
408 esc_html__( 'Track AI Bots using Edge Side Includes', 'matomo' ),
409 esc_html__( 'If you are using a CDN to serve your blog, you will not be able to track AI bots in the traditional method. If your CDN supports ESI (Edge Side Includes), however, you can enable this option to use this feature for tracking AI bots.', 'matomo' ),
410 ! $matomo_is_track_ai_enabled,
411 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager matomo-track-ai-using-esi'
412 );
413
414 if ( $matomo_is_using_litespeed && $matomo_is_using_litespeed_cache ) {
415 if ( ! $matomo_is_track_via_esi_enabled ) {
416 ?>
417 <tr>
418 <td></td>
419 <td>
420 <div class="matomo-inline-notice matomo-warning matomo-track-ai-warning" style="<?php echo $matomo_is_track_ai_enabled ? '' : 'display:none;'; ?>">
421 <p>
422 <strong><?php esc_html_e( 'Warning', 'matomo' ); ?>:</strong>
423 <?php esc_html_e( 'We noticed you are using a LiteSpeed webserver with the LiteSpeed Cache plugin. Tracking AI bots with LiteSpeed can only be accomplished via ESI. Please enable the feature both here and in your LiteSpeed webserver.', 'matomo' ); ?>
424 </p>
425 </div>
426 </td>
427 </tr>
428 <?php
429 } elseif ( ! $matomo_is_esi_enabled_in_litespeed ) {
430 ?>
431 <tr>
432 <td></td>
433 <td>
434 <div class="matomo-inline-notice matomo-warning matomo-track-ai-warning" style="<?php echo $matomo_is_track_ai_enabled ? '' : 'display:none;'; ?>">
435 <p>
436 <strong><?php esc_html_e( 'Warning', 'matomo' ); ?>:</strong>
437 <?php
438 echo sprintf(
439 esc_html__( 'ESI is not currently enabled in your LiteSpeed webserver. To track AI bots with LiteSpeed it is required to enable this feature. %1$sSee LiteSpeed docs for more info.%2$s', 'matomo' ),
440 '<a href="https://docs.litespeedtech.com/lscache/lscwp/cache/#esi-tab" target="_blank" rel="noreferrer noopener">',
441 '</a>'
442 );
443 ?>
444 </p>
445 </div>
446 </td>
447 </tr>
448 <?php
449 }
450 }
451
452 ?>
453 </tbody>
454 </table>
455
456 <h4><?php esc_html_e( 'Create Matomo annotations on', 'matomo' ); ?></h4>
457 <table class="matomo-tracking-form widefat">
458 <tbody>
459 <?php
460 echo '<tr class="' . esc_attr( $matomo_full_generated_tracking_group ) . ' matomo-track-option-manually">';
461 echo '<th scope="row"><label for="add_post_annotations">' . esc_html__( 'On new post of type', 'matomo' ) . ':</label></th><td>';
462 echo '<div class="post-types">';
463 $matomo_filter = $settings->get_global_option( 'add_post_annotations' );
464 foreach ( get_post_types( [], 'objects' ) as $object_post_type ) {
465 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>';
466 }
467 echo '</div>';
468 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>';
469 ?>
470 </tbody>
471 </table>
472
473 <h4><?php esc_html_e( 'Advanced', 'matomo' ); ?></h4>
474 <table class="matomo-tracking-form widefat">
475 <tbody>
476 <?php
477 $matomo_form->show_checkbox(
478 'track_noscript',
479 __( 'Add &lt;noscript&gt; to track visitors who disable JavaScript', 'matomo' ),
480 __( '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' )
481 . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Tag Manager tracking mode.', 'matomo' ) . '</em>',
482 false,
483 'matomo-track-option matomo-track-option-default matomo-track-option-manually'
484 );
485 ?>
486 </tbody>
487 </table>
488 </div>
489
490 <hr/>
491
492 <div id="auto-tracking-settings" class="collapsible-settings" data-settings-for="default">
493 <h2 data-inactive-title="<?php esc_attr_e( 'Note: these settings will only apply if the Auto tracking mode is active.', 'matomo' ); ?>">
494 <?php esc_html_e( 'Settings for Auto Tracking mode', 'matomo' ); ?>
495 <span class="inactive-notice">(<?php esc_html_e( 'Inactive', 'matomo' ); ?>)</span>
496 </h2>
497 <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>
498 <p id="showGeneratedTrackingCode"><a href="#"><?php esc_html_e( 'Show generated tracking code', 'matomo' ); ?></a></p>
499 <p id="hideGeneratedTrackingCode" style="display:none;"><a href="#"><?php esc_html_e( 'Hide generated tracking code', 'matomo' ); ?></a></p>
500 <table class="matomo-tracking-form widefat" id="generatedTrackingCode" style="display:none;margin-bottom:1em;">
501 <?php
502 $matomo_form->show_textarea(
503 'generated_tracking_code',
504 esc_html__( 'Tracking code', 'matomo' ),
505 15,
506 sprintf(
507 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' ),
508 $matomo_manually_network
509 ),
510 false,
511 '',
512 false,
513 '',
514 true,
515 false,
516 true
517 );
518
519 $matomo_form->show_textarea(
520 'generated_noscript_code',
521 esc_html__( '<noscript> code', 'matomo' ),
522 2,
523 __( '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' ),
524 false,
525 '',
526 false,
527 '',
528 true,
529 false,
530 true
531 );
532 ?>
533 </table>
534 <script>
535 jQuery('#showGeneratedTrackingCode,#hideGeneratedTrackingCode').on('click', 'a', function (e) {
536 e.preventDefault();
537 e.stopPropagation();
538 jQuery('#generatedTrackingCode,#showGeneratedTrackingCode,#hideGeneratedTrackingCode').toggle();
539 });
540 </script>
541
542 <h4><?php esc_html_e( 'Privacy', 'matomo' ); ?></h4>
543 <table class="matomo-tracking-form widefat">
544 <tbody>
545 <?php
546 $matomo_form->show_checkbox(
547 'disable_cookies',
548 esc_html__( 'Disable cookies', 'matomo' ),
549 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' ),
550 false,
551 $matomo_full_generated_tracking_group
552 );
553
554 $matomo_form->show_checkbox(
555 'limit_cookies',
556 esc_html__( 'Limit cookie lifetime', 'matomo' ),
557 esc_html__( 'If necessary, you can limit the cookie lifetime to avoid tracking your users over a longer period.', 'matomo' ),
558 false,
559 $matomo_full_generated_tracking_group,
560 false,
561 'jQuery(\'tr.matomo-cookielifetime-option\').toggleClass(\'hidden\');'
562 );
563
564 $matomo_form->show_input(
565 'limit_cookies_visitor',
566 esc_html__( 'Visitor timeout (seconds)', 'matomo' ),
567 false,
568 ! $settings->get_global_option( 'limit_cookies' ),
569 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
570 );
571
572 $matomo_form->show_input(
573 'limit_cookies_session',
574 esc_html__( 'Session timeout (seconds)', 'matomo' ),
575 false,
576 ! $settings->get_global_option( 'limit_cookies' ),
577 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
578 );
579
580 $matomo_form->show_input(
581 'limit_cookies_referral',
582 esc_html__( 'Referral timeout (seconds)', 'matomo' ),
583 false,
584 ! $settings->get_global_option( 'limit_cookies' ),
585 $matomo_full_generated_tracking_group . ' matomo-cookielifetime-option'
586 );
587 ?>
588 </tbody>
589 </table>
590
591 <h4><?php esc_html_e( 'Subdomains', 'matomo' ); ?></h4>
592 <table class="matomo-tracking-form widefat">
593 <tbody>
594 <?php
595 $matomo_form->show_checkbox(
596 'track_across',
597 esc_html__( 'Track subdomains in the same website', 'matomo' ),
598 esc_html__( 'Track visitors across subdomains by adding a *.-prefix to the cookie domain.', 'matomo' ) . ' ' .
599 sprintf(
600 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
601 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#tracking-subdomains-in-the-same-website" rel="noreferrer noopener" target="_BLANK">',
602 '</a>'
603 ),
604 false,
605 $matomo_full_generated_tracking_group
606 );
607
608 $matomo_form->show_checkbox(
609 'track_across_alias',
610 esc_html__( 'Do not count subdomains as outlink', 'matomo' ),
611 esc_html__( 'Treats all subdomains as part of the same website, by adding a *.-prefix to the tracked domain.', 'matomo' ) . ' ' .
612 sprintf(
613 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
614 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#outlink-tracking-exclusions" rel="noreferrer noopener" target="_BLANK">',
615 '</a>'
616 ),
617 false,
618 $matomo_full_generated_tracking_group
619 );
620
621 $matomo_form->show_checkbox(
622 'track_crossdomain_linking',
623 esc_html__( 'Enable cross domain linking', 'matomo' ),
624 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' ),
625 false,
626 $matomo_full_generated_tracking_group
627 );
628 ?>
629 </tbody>
630 </table>
631
632 <h4><?php esc_html_e( 'Link Tracking', 'matomo' ); ?></h4>
633 <table class="matomo-tracking-form widefat">
634 <tbody>
635 <?php
636 $matomo_form->show_input(
637 'add_download_extensions',
638 esc_html__( 'Add new file types for download tracking', 'matomo' ),
639 sprintf(
640 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' ),
641 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#tracking-file-downloads" rel="noreferrer noopener" target="_BLANK">',
642 '</a>'
643 ),
644 false,
645 $matomo_full_generated_tracking_group
646 );
647
648 $matomo_form->show_input(
649 'set_download_extensions',
650 esc_html__( 'Define all file types for download tracking', 'matomo' ),
651 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' ) . ' ' .
652 sprintf(
653 esc_html__( 'See %1$sMatomo documentation%2$s.', 'matomo' ),
654 '<a href="https://developer.matomo.org/guides/tracking-javascript-guide#file-extensions-for-tracking-downloads" target="_BLANK">',
655 '</a>'
656 ),
657 false,
658 $matomo_full_generated_tracking_group
659 );
660
661 $matomo_form->show_input(
662 'set_download_classes',
663 esc_html__( 'Set CSS classes to be treated as downloads', 'matomo' ),
664 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' ) . ' ' .
665 sprintf(
666 esc_html__( 'See %1$sMatomo JavaScript Tracking Client reference%2$s.', 'matomo' ),
667 '<a href="https://developer.matomo.org/api-reference/tracking-javascript" target="_BLANK">',
668 '</a>'
669 ),
670 false,
671 $matomo_full_generated_tracking_group
672 );
673
674 $matomo_form->show_input(
675 'set_link_classes',
676 esc_html__( 'Set CSS classes to be treated as outlinks', 'matomo' ),
677 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' ) . ' ' .
678 sprintf(
679 esc_html__( 'See %1$sMatomo JavaScript Tracking Client reference%2$s.', 'matomo' ),
680 '<a href="https://developer.matomo.org/api-reference/tracking-javascript" target="_BLANK">',
681 '</a>'
682 ),
683 false,
684 $matomo_full_generated_tracking_group
685 );
686 ?>
687 </tbody>
688 </table>
689
690 <h4><?php esc_html_e( 'Other Tracking', 'matomo' ); ?></h4>
691 <table class="matomo-tracking-form widefat">
692 <tbody>
693 <?php
694 $matomo_form->show_checkbox(
695 'track_jserrors',
696 esc_html__( 'Track JS errors', 'matomo' ),
697 esc_html__( 'Enable to track JavaScript errors that occur on your website as Matomo events.', 'matomo' )
698 . ' ' . 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>' )
699 . ' ' . 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>' ),
700 false,
701 $matomo_full_generated_tracking_group
702 );
703
704 $matomo_form->show_select(
705 'track_content',
706 __( 'Enable content tracking', 'matomo' ),
707 [
708 'disabled' => esc_html__( 'Disabled', 'matomo' ),
709 'all' => esc_html__( 'Track all content blocks', 'matomo' ),
710 'visible' => esc_html__( 'Track only visible content blocks', 'matomo' ),
711 ],
712 __( '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>' ),
713 '',
714 false,
715 $matomo_full_generated_tracking_group
716 );
717
718 $matomo_form->show_input(
719 'track_heartbeat',
720 esc_html__( 'Enable heartbeat timer (enable with care)', 'matomo' ),
721 __( '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' ),
722 false,
723 $matomo_full_generated_tracking_group
724 );
725 ?>
726 </tbody>
727 </table>
728
729 <h4><?php esc_html_e( 'Advanced', 'matomo' ); ?></h4>
730 <table class="matomo-tracking-form widefat">
731 <tbody>
732 <?php
733 $matomo_form->show_checkbox(
734 'force_post',
735 esc_html__( 'Force POST requests', 'matomo' ),
736 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' ),
737 false,
738 $matomo_full_generated_tracking_group
739 );
740
741 $matomo_form->show_select(
742 'cookie_consent',
743 esc_html__( 'Custom consent screen', 'matomo' ),
744 $cookie_consent_modes,
745 sprintf(
746 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' ),
747 '<a href="https://developer.matomo.org/guides/tracking-consent" rel="noreferrer noopener" target="_blank">',
748 '</a>'
749 ),
750 '',
751 false,
752 $matomo_full_generated_tracking_group
753 );
754
755 $matomo_form->show_select(
756 'track_api_endpoint',
757 __( 'Endpoint for HTTP Tracking API', 'matomo' ),
758 [
759 'default' => esc_html__( 'Default', 'matomo' ),
760 'restapi' => esc_html__( 'Through WordPress Rest API', 'matomo' ),
761 ],
762 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() ) ),
763 '',
764 false,
765 $matomo_full_generated_tracking_group . ' matomo-track-option-manually matomo-track-option-tagmanager'
766 );
767
768 $matomo_form->show_select(
769 'track_js_endpoint',
770 __( 'Endpoint for JavaScript tracker', 'matomo' ),
771 [
772 'default' => esc_html__( 'Default', 'matomo' ),
773 'restapi' => esc_html__( 'Through WordPress Rest API (slower)', 'matomo' ),
774 'plugin' => esc_html__( 'Plugin (an alternative JS file if the default is blocked by the webserver)', 'matomo' ),
775 ],
776 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() ) ),
777 '',
778 false,
779 $matomo_full_generated_tracking_group
780 );
781 ?>
782 </tbody>
783 </table>
784 </div>
785
786 <hr/>
787
788 <div id="manual-tracking-settings" class="collapsible-settings" data-settings-for="manually">
789 <h2 data-inactive-title="<?php esc_attr_e( 'Note: these settings will only apply if the Manual tracking mode is active.', 'matomo' ); ?>">
790 <?php esc_html_e( 'Settings for Manual Tracking mode', 'matomo' ); ?>
791 <span class="inactive-notice">(<?php esc_html_e( 'Inactive', 'matomo' ); ?>)</span>
792 </h2>
793 <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>
794 <table class="matomo-tracking-form widefat">
795 <tbody>
796 <?php
797 $matomo_form->show_textarea(
798 'tracking_code',
799 esc_html__( 'Tracking code', 'matomo' ),
800 15,
801 sprintf(
802 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' ),
803 $matomo_manually_network
804 ),
805 false,
806 'matomo-track-option matomo-track-option-default matomo-track-option-tagmanager matomo-track-option-manually',
807 ! $settings->is_network_enabled(),
808 '',
809 false,
810 false
811 );
812
813 $matomo_form->show_textarea(
814 'noscript_code',
815 esc_html__( 'Noscript code', 'matomo' ),
816 2,
817 __( 'Enter your custom &lt;noscript&gt; code here. This will only show if the noscript feature is enabled.', 'matomo' ),
818 false,
819 'matomo-track-option matomo-track-option-default matomo-track-option-manually',
820 true,
821 '',
822 false,
823 false
824 );
825 ?>
826 </tbody>
827 </table>
828 </div>
829
830 <hr/>
831
832 <div id="html-tag-settings" class="collapsible-settings">
833 <h2><?php esc_html_e( '<script> Tag Settings', 'matomo' ); ?></h2>
834 <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>
835 <table class="matomo-tracking-form widefat">
836 <tbody>
837 <?php
838 $matomo_form->show_select(
839 'force_protocol',
840 __( 'Force Matomo to use a specific protocol', 'matomo' ),
841 [
842 'disabled' => esc_html__( 'Disabled (default)', 'matomo' ),
843 'https' => esc_html__( 'https (SSL)', 'matomo' ),
844 ],
845 __( 'Choose if you want to force Matomo to use HTTP or HTTPS.', 'matomo' )
846 . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Manual tracking mode.', 'matomo' ) . '</em>',
847 '',
848 false,
849 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
850 );
851 $matomo_form->show_select(
852 'track_codeposition',
853 __( 'JavaScript code position', 'matomo' ),
854 [
855 'footer' => esc_html__( 'Footer', 'matomo' ),
856 'header' => esc_html__( 'Header', 'matomo' ),
857 ],
858 __( 'Choose whether the JavaScript code is added to the footer or the header.', 'matomo' ),
859 '',
860 false,
861 'matomo-track-option matomo-track-option-default matomo-track-option-tagmanager matomo-track-option-manually'
862 );
863
864 $matomo_form->show_checkbox(
865 'track_datacfasync',
866 esc_html__( 'Add data-cfasync=false', 'matomo' ),
867 esc_html__( 'Adds data-cfasync=false to the script tag, e.g., to ask Rocket Loader to ignore the script.', 'matomo' ) . ' ' .
868 sprintf(
869 esc_html__( 'See %1$sCloudFlare Knowledge Base%2$s.', 'matomo' ),
870 '<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">',
871 '</a>'
872 ) . '<br/><br/><em>' . esc_html__( 'This setting does not apply to the Manual tracking mode.', 'matomo' ) . '</em>',
873 false,
874 $matomo_full_generated_tracking_group . ' matomo-track-option-tagmanager'
875 );
876 ?>
877 </tbody>
878 </table>
879 </div>
880
881 <hr/>
882
883 <div id="developer-settings" class="collapsible-settings">
884 <h2><?php esc_html_e( 'Developer Settings', 'matomo' ); ?></h2>
885 <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>
886 <table class="matomo-tracking-form widefat">
887 <tbody>
888 <?php
889 $matomo_form->show_select(
890 'tracker_debug',
891 __( 'Tracker Debug Mode', 'matomo' ),
892 [
893 'disabled' => esc_html__( 'Disabled (recommended)', 'matomo' ),
894 'always' => esc_html__( 'Always enabled', 'matomo' ),
895 'on_demand' => esc_html__( 'Enabled on demand', 'matomo' ),
896 ],
897 __( 'For security and privacy reasons you should only enable this setting for as short time of a time as possible.', 'matomo' )
898 . '<br/>'
899 . __( 'If enabling on demand, add \'&debug=1\' to tracker requests to trigger debug output.', 'matomo' ),
900 '',
901 false,
902 $matomo_full_generated_tracking_group . ' matomo-track-option-disabled matomo-track-option-manually matomo-track-option-tagmanager'
903 );
904 ?>
905 </tbody>
906 </table>
907 </div>
908
909 <p>
910 <?php
911 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
912 echo $matomo_submit_button;
913 ?>
914 </p>
915 </form>
916
917 <?php if ( ! $settings->is_network_enabled() ) { // Can't show it for multisite as idsite and url is always different. ?>
918 <div id="matomo_default_tracking_code">
919 <h2><?php esc_html_e( 'JavaScript tracking code', 'matomo' ); ?></h2>
920 <p>
921 <?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>' ); ?>
922 </p>
923 <?php echo '<pre><textarea readonly="readonly">' . esc_html( preg_replace( '/\\n+/', "\n", implode( ";\n", explode( ';', $matomo_default_tracking_code['script'] ) ) ) ) . '</textarea></pre>'; ?>
924 <h3><?php esc_html_e( '<noscript> tracking code', 'matomo' ); ?></h3>
925 <?php echo '<pre><textarea readonly="readonly" class="no_script">' . esc_html( $matomo_default_tracking_code['noscript'] ) . '</textarea></pre>'; ?>
926 </div>
927 <?php } ?>
928