From 801bcdede9a21b6353850726e0430c916d46da2d Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Thu, 13 Apr 2023 13:45:32 +0200 Subject: [PATCH 01/11] Track searches --- src/Includes/Actions.php | 8 ++++++++ src/Includes/Helpers.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/Includes/Actions.php b/src/Includes/Actions.php index 068e7d89..47c38e00 100644 --- a/src/Includes/Actions.php +++ b/src/Includes/Actions.php @@ -66,6 +66,14 @@ public function maybe_register_assets() { if ( apply_filters( 'plausible_analytics_enable_404', true ) && is_404() ) { wp_add_inline_script( 'plausible-analytics', 'plausible("404",{ props: { path: document.location.pathname } });' ); } + + // Track search results. Tracks a search event with the search term and the number of results, and a pageview with the site's search URL. + if ( apply_filters( 'plausible_analytics_track_search', true ) && is_search() ) { + $search_url = str_replace( '%search%', '', get_site_url( null, $GLOBALS['wp_rewrite']->get_search_permastruct() ) ); + $data = 'plausible("pageview", { u: "' . esc_attr( $search_url ) . '" });' . + 'plausible( \'Search\', {props: {keyword: \'' . get_search_query() . '\', resultCount: ' . $GLOBALS['wp_query']->found_posts . '}});'; + wp_add_inline_script( 'plausible-analytics', $data ); + } } /** diff --git a/src/Includes/Helpers.php b/src/Includes/Helpers.php index d4508ede..2d759510 100644 --- a/src/Includes/Helpers.php +++ b/src/Includes/Helpers.php @@ -70,6 +70,11 @@ public static function get_analytics_url() { $domain = $settings['self_hosted_domain']; } + if ( is_search() ) { + // Add the manual scripts as we need it to track the search parameter. + $file_name .= '.manual'; + } + $url = "https://{$domain}/js/{$file_name}.js"; return esc_url( $url ); From a9f975a8c7b01d1d03073831f1ac677ea33fbac8 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Thu, 13 Apr 2023 13:47:32 +0200 Subject: [PATCH 02/11] Make sure resultCount is an int --- src/Includes/Actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Includes/Actions.php b/src/Includes/Actions.php index 47c38e00..af0150c1 100644 --- a/src/Includes/Actions.php +++ b/src/Includes/Actions.php @@ -71,7 +71,7 @@ public function maybe_register_assets() { if ( apply_filters( 'plausible_analytics_track_search', true ) && is_search() ) { $search_url = str_replace( '%search%', '', get_site_url( null, $GLOBALS['wp_rewrite']->get_search_permastruct() ) ); $data = 'plausible("pageview", { u: "' . esc_attr( $search_url ) . '" });' . - 'plausible( \'Search\', {props: {keyword: \'' . get_search_query() . '\', resultCount: ' . $GLOBALS['wp_query']->found_posts . '}});'; + 'plausible( \'Search\', {props: {keyword: \'' . get_search_query() . '\', resultCount: ' . intval( $GLOBALS['wp_query']->found_posts ) . '}});'; wp_add_inline_script( 'plausible-analytics', $data ); } } From 62e2580d81551c6dfc84afebc6fe5e359ec380af Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Thu, 6 Jun 2024 08:46:25 +0200 Subject: [PATCH 03/11] Use get_domain() where applicable, and removed some unused code. --- src/Admin/Settings/Hooks.php | 22 ---- src/Filters.php | 2 +- src/Includes/Helpers.php | 191 +++++++++++++++++------------------ 3 files changed, 94 insertions(+), 121 deletions(-) diff --git a/src/Admin/Settings/Hooks.php b/src/Admin/Settings/Hooks.php index 0234f8f1..0ffcef07 100644 --- a/src/Admin/Settings/Hooks.php +++ b/src/Admin/Settings/Hooks.php @@ -33,7 +33,6 @@ public function __construct( $init = true ) { */ private function init_hooks() { add_filter( 'plausible_analytics_toggle_option_success_message', [ $this, 'maybe_modify_success_message' ], 10, 3 ); - add_action( 'plausible_analytics_settings_api_connect_button', [ $this, 'connect_button' ] ); add_action( 'plausible_analytics_settings_api_token_missing', [ $this, 'missing_api_token_warning' ] ); add_action( 'plausible_analytics_settings_option_not_available_in_ce', [ $this, 'option_na_in_ce' ] ); add_action( 'plausible_analytics_settings_proxy_warning', [ $this, 'proxy_warning' ] ); @@ -63,27 +62,6 @@ public function maybe_modify_success_message( $message, $option_name, $status ) return __( 'Proxy enabled.', 'plausible-analytics' ); } - /** - * Display connect button. - * - * @output HTML - */ - public function connect_button() { - $settings = Helpers::get_settings(); - - if ( ! empty( $settings[ 'domain_name' ] ) && ! empty( $settings[ 'api_token' ] ) ): ?> - - - - - - - - '', + 'enhanced_measurements' => [], + 'shared_link' => '', + 'excluded_pages' => '', + 'tracked_user_roles' => [], + 'expand_dashboard_access' => [], + 'disable_toolbar_menu' => '', + 'self_hosted_domain' => '', + ]; + + $settings = get_option( 'plausible_analytics_settings', [] ); + + return wp_parse_args( $settings, $defaults ); + } + /** * Get Dashboard URL. * @@ -89,20 +96,33 @@ public static function get_analytics_url() { * @return string */ public static function get_analytics_dashboard_url() { - $settings = self::get_settings(); - $domain = $settings['domain_name']; + $domain = Helpers::get_domain(); return esc_url( "https://plausible.io/{$domain}" ); } /** - * Toggle Switch HTML Markup. + * Get Plain Domain (without protocol or www. subdomain) * - * @param string $name Name of the toggle switch. + * @since 1.0.0 + * @access public + * + * @return string + */ + public static function get_domain() { + $url = home_url(); + + return preg_replace( '/^http(s?)\:\/\/(www\.)?/i', '', $url ); + } + + /** + * Toggle Switch HTML Markup. * * @since 1.0.0 * @access public * + * @param string $name Name of the toggle switch. + * * @return void */ public static function display_toggle_switch( $name ) { @@ -110,37 +130,14 @@ public static function display_toggle_switch( $name ) { $individual_settings = ! empty( $settings[ $name ] ) ? esc_html( $settings[ $name ] ) : ''; ?> '', - 'enhanced_measurements' => [], - 'shared_link' => '', - 'excluded_pages' => '', - 'tracked_user_roles' => [], - 'expand_dashboard_access' => [], - 'disable_toolbar_menu' => '', - 'self_hosted_domain' => '', - ]; - - $settings = get_option( 'plausible_analytics_settings', [] ); - - return wp_parse_args( $settings, $defaults ); - } - /** * Get Data API URL. * @@ -154,16 +151,54 @@ public static function get_data_api_url() { $url = 'https://plausible.io/api/event'; // Triggered when self hosted analytics is enabled. - if ( - ! empty( $settings['self_hosted_domain'] ) - ) { - $default_domain = $settings['self_hosted_domain']; + if ( ! empty( $settings[ 'self_hosted_domain' ] ) ) { + $default_domain = $settings[ 'self_hosted_domain' ]; $url = "https://{$default_domain}/api/event"; } return esc_url( $url ); } + /** + * Render Quick Actions + * + * @since 1.3.0 + * @access public + * + * @return string + */ + public static function render_quick_actions() { + ob_start(); + $quick_actions = self::get_quick_actions(); + ?> +
+ 0 ) { + ?> +
+ +
+ + +
+ -
- 0 ) { - ?> -
- -
- - -
- Date: Thu, 6 Jun 2024 08:48:05 +0200 Subject: [PATCH 04/11] Rearranged actions. --- src/Admin/Settings/Hooks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Admin/Settings/Hooks.php b/src/Admin/Settings/Hooks.php index 0ffcef07..4570a5f2 100644 --- a/src/Admin/Settings/Hooks.php +++ b/src/Admin/Settings/Hooks.php @@ -34,11 +34,11 @@ public function __construct( $init = true ) { private function init_hooks() { add_filter( 'plausible_analytics_toggle_option_success_message', [ $this, 'maybe_modify_success_message' ], 10, 3 ); add_action( 'plausible_analytics_settings_api_token_missing', [ $this, 'missing_api_token_warning' ] ); - add_action( 'plausible_analytics_settings_option_not_available_in_ce', [ $this, 'option_na_in_ce' ] ); - add_action( 'plausible_analytics_settings_proxy_warning', [ $this, 'proxy_warning' ] ); add_action( 'plausible_analytics_settings_enable_analytics_dashboard_notice', [ $this, 'enable_analytics_dashboard_notice' ] ); add_action( 'plausible_analytics_settings_option_disabled_by_missing_api_token', [ $this, 'option_disabled_by_missing_api_token' ] ); add_action( 'plausible_analytics_settings_option_disabled_by_proxy', [ $this, 'option_disabled_by_proxy' ] ); + add_action( 'plausible_analytics_settings_option_not_available_in_ce', [ $this, 'option_na_in_ce' ] ); + add_action( 'plausible_analytics_settings_proxy_warning', [ $this, 'proxy_warning' ] ); } /** From 0b955a139217286c61dba70437df812edd0064f8 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:15:35 +0200 Subject: [PATCH 05/11] Remove unnecessary escape. --- src/Helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers.php b/src/Helpers.php index a0819788..5c76c9ed 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -262,7 +262,7 @@ public static function get_domain() { $url = home_url(); - return preg_replace( '/^http(s?)\:\/\/(www\.)?/i', '', $url ); + return preg_replace( '/^http(s?):\/\/(www\.)?/i', '', $url ); } /** From 5ba4d901c9489ff2a6d0265cd19bbc1cb600b8be Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:16:04 +0200 Subject: [PATCH 06/11] PHPDoc. --- src/Helpers.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Helpers.php b/src/Helpers.php index 5c76c9ed..360ee733 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -271,10 +271,11 @@ public static function get_domain() { * @since 1.2.2 * @access public * @return string + * @throws Exception */ public static function get_data_api_url() { if ( self::proxy_enabled() ) { - // This'll make sure the API endpoint is properly registered when we're testing. + // This will make sure the API endpoint is properly registered when we're testing. $append = isset( $_GET[ 'plausible_proxy' ] ) ? '?plausible_proxy=1' : ''; return self::get_rest_endpoint() . $append; From 178d5ed6011158cb10a20eb6770e2c7988147a33 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:13:16 +0200 Subject: [PATCH 07/11] Fixed merge conflicts and refactored code for readability. --- src/Actions.php | 19 +++ src/Helpers.php | 5 + src/Includes/Actions.php | 133 -------------------- src/Includes/Helpers.php | 261 --------------------------------------- 4 files changed, 24 insertions(+), 394 deletions(-) delete mode 100644 src/Includes/Actions.php delete mode 100644 src/Includes/Helpers.php diff --git a/src/Actions.php b/src/Actions.php index ac9250b9..6c31b930 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -73,6 +73,25 @@ public function maybe_register_assets() { ); } + // Track search results. Tracks a search event with the search term and the number of results, and a pageview with the site's search URL. + if ( apply_filters( 'plausible_analytics_track_search', true ) && is_search() ) { + global $wp_rewrite, $wp_query; + + $search_url = str_replace( '%search%', '', get_site_url( null, $wp_rewrite->get_search_permastruct() ) ); + $data = wp_json_encode( + [ + 'props' => [ + 'keyword' => get_search_query(), + 'resultCount' => intval( $wp_query->found_posts ), + ], + ] + ); + $script = 'plausible( "pageview", { u: "' . esc_attr( $search_url ) . '" } );'; + $script .= "\n" . "plausible( 'Search', $data );"; + + wp_add_inline_script( 'plausible-analytics', $script ); + } + // This action allows you to add your own custom scripts! do_action( 'plausible_analytics_after_register_assets', $settings ); } diff --git a/src/Helpers.php b/src/Helpers.php index 360ee733..1566b305 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -62,6 +62,11 @@ public static function get_filename( $local = false ) { $file_name .= '.' . 'exclusions'; } + // Add the manual scripts as we need it to track the search parameter. + if ( is_search() ) { + $file_name .= '.manual'; + } + return $file_name; } diff --git a/src/Includes/Actions.php b/src/Includes/Actions.php deleted file mode 100644 index af0150c1..00000000 --- a/src/Includes/Actions.php +++ /dev/null @@ -1,133 +0,0 @@ -get_search_permastruct() ) ); - $data = 'plausible("pageview", { u: "' . esc_attr( $search_url ) . '" });' . - 'plausible( \'Search\', {props: {keyword: \'' . get_search_query() . '\', resultCount: ' . intval( $GLOBALS['wp_query']->found_posts ) . '}});'; - wp_add_inline_script( 'plausible-analytics', $data ); - } - } - - /** - * Create admin bar nodes. - * - * @param \WP_Admin_Bar $admin_bar Admin bar object. - * - * @return void - * @since 1.3.0 - * @access public - */ - public function admin_bar_node( $admin_bar ) { - $disable = ! empty( Helpers::get_settings()['disable_toolbar_menu'][0] ); - - if ( $disable ) { - return; - } - - // Add main admin bar node. - $args = [ - 'id' => 'plausible-admin-bar', - 'title' => 'Plausible Analytics', - ]; - $admin_bar->add_node( $args ); - - // Add link to view all stats. - $args = []; - $args[] = [ - 'id' => 'view-analytics', - 'title' => esc_html__( 'View Analytics', 'plausible-analytics' ), - 'href' => admin_url( 'index.php?page=plausible_analytics_statistics' ), - 'parent' => 'plausible-admin-bar', - ]; - - // Add link to individual page stats. - if ( is_singular() ) { - global $post; - $args[] = [ - 'id' => 'view-page-analytics', - 'title' => esc_html__( 'View Page Analytics', 'plausible-analytics' ), - 'href' => add_query_arg( 'page-url', is_home() ? '' : trailingslashit( urlencode( '/' . $post->post_name ) ), admin_url( 'index.php?page=plausible_analytics_statistics' ) ), - 'parent' => 'plausible-admin-bar', - ]; - } - - // Add link to Plausible Settings page. - $args[] = [ - 'id' => 'settings', - 'title' => esc_html__( 'Settings', 'plausible-analytics' ), - 'href' => admin_url( 'options-general.php?page=plausible_analytics' ), - 'parent' => 'plausible-admin-bar', - ]; - foreach ( $args as $arg ) { - $admin_bar->add_node( $arg ); - } - } -} diff --git a/src/Includes/Helpers.php b/src/Includes/Helpers.php deleted file mode 100644 index 62b9cdea..00000000 --- a/src/Includes/Helpers.php +++ /dev/null @@ -1,261 +0,0 @@ - '', - 'enhanced_measurements' => [], - 'shared_link' => '', - 'excluded_pages' => '', - 'tracked_user_roles' => [], - 'expand_dashboard_access' => [], - 'disable_toolbar_menu' => '', - 'self_hosted_domain' => '', - ]; - - $settings = get_option( 'plausible_analytics_settings', [] ); - - return wp_parse_args( $settings, $defaults ); - } - - /** - * Get Dashboard URL. - * - * @since 1.0.0 - * @access public - * - * @return string - */ - public static function get_analytics_dashboard_url() { - $domain = Helpers::get_domain(); - - return esc_url( "https://plausible.io/{$domain}" ); - } - - /** - * Get Plain Domain (without protocol or www. subdomain) - * - * @since 1.0.0 - * @access public - * - * @return string - */ - public static function get_domain() { - $url = home_url(); - - return preg_replace( '/^http(s?)\:\/\/(www\.)?/i', '', $url ); - } - - /** - * Toggle Switch HTML Markup. - * - * @since 1.0.0 - * @access public - * - * @param string $name Name of the toggle switch. - * - * @return void - */ - public static function display_toggle_switch( $name ) { - $settings = Helpers::get_settings(); - $individual_settings = ! empty( $settings[ $name ] ) ? esc_html( $settings[ $name ] ) : ''; - ?> - - -
- 0 ) { - ?> -
- -
- - -
- [ - 'label' => esc_html__( 'Documentation', 'plausible-analytics' ), - 'url' => esc_url( 'https://docs.plausible.io/' ), - ], - 'report-issue' => [ - 'label' => esc_html__( 'Report an issue', 'plausible-analytics' ), - 'url' => esc_url( 'https://github.com/plausible/wordpress/issues/new' ), - ], - 'translate-plugin' => [ - 'label' => esc_html__( 'Translate Plugin', 'plausible-analytics' ), - 'url' => esc_url( 'https://translate.wordpress.org/projects/wp-plugins/plausible-analytics/' ), - ], - ]; - } - - /** - * Clean variables using `sanitize_text_field`. - * Arrays are cleaned recursively. Non-scalar values are ignored. - * - * @since 1.3.0 - * @access public - * - * @param string|array $var Sanitize the variable. - * - * @return string|array - */ - public static function clean( $var ) { - if ( is_array( $var ) ) { - return array_map( [ __CLASS__, __METHOD__ ], $var ); - } - - return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var; - } - - /** - * Get user role for the logged-in user. - * - * @since 1.3.0 - * @access public - * - * @return string - */ - public static function get_user_role() { - global $current_user; - - $user_roles = $current_user->roles; - - return array_shift( $user_roles ); - } -} From ab66877ed46344fb92d36482d27e50be21888ed0 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:04:56 +0200 Subject: [PATCH 08/11] Added: Search Queries option to Enhanced Measurements and included auto provisioning of custom properties and (pageview) event goals. --- src/Actions.php | 24 ++++++++++++++++-------- src/Admin/Provisioning.php | 33 +++++++++++++++++++++++++++++++-- src/Admin/Settings/Page.php | 9 ++++++++- src/Helpers.php | 8 ++++++-- 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/Actions.php b/src/Actions.php index 6c31b930..4627d54b 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -66,30 +66,38 @@ public function maybe_register_assets() { ); // Track 404 pages (if enabled) - if ( is_array( $settings[ 'enhanced_measurements' ] ) && in_array( '404', $settings[ 'enhanced_measurements' ] ) && is_404() ) { + if ( Helpers::is_enhanced_measurement_enabled( '404' ) && is_404() ) { + $data = wp_json_encode( + [ + 'props' => [ + 'path' => 'documentation.location.pathname', + ], + ] + ); + wp_add_inline_script( 'plausible-analytics', - "document.addEventListener('DOMContentLoaded', function () { plausible('404', { props: { path: document.location.pathname } }); });" + "document.addEventListener('DOMContentLoaded', function () { plausible( '404', $data ); });" ); } // Track search results. Tracks a search event with the search term and the number of results, and a pageview with the site's search URL. - if ( apply_filters( 'plausible_analytics_track_search', true ) && is_search() ) { + if ( Helpers::is_enhanced_measurement_enabled( 'search' ) && is_search() ) { global $wp_rewrite, $wp_query; $search_url = str_replace( '%search%', '', get_site_url( null, $wp_rewrite->get_search_permastruct() ) ); $data = wp_json_encode( [ 'props' => [ - 'keyword' => get_search_query(), - 'resultCount' => intval( $wp_query->found_posts ), + 'search_query' => get_search_query(), + 'result_count' => intval( $wp_query->found_posts ), ], ] ); - $script = 'plausible( "pageview", { u: "' . esc_attr( $search_url ) . '" } );'; - $script .= "\n" . "plausible( 'Search', $data );"; + $script = 'plausible("pageview", {u:"' . esc_attr( $search_url ) . '"});'; + $script .= "\nplausible('Search', $data );"; - wp_add_inline_script( 'plausible-analytics', $script ); + wp_add_inline_script( 'plausible-analytics', "document.addEventListener('DOMContentLoaded', function() {\n$script\n});" ); } // This action allows you to add your own custom scripts! diff --git a/src/Admin/Provisioning.php b/src/Admin/Provisioning.php index 2ad99435..12cee82d 100644 --- a/src/Admin/Provisioning.php +++ b/src/Admin/Provisioning.php @@ -35,6 +35,11 @@ class Provisioning { 'category', ]; + private $custom_search_properties = [ + 'search_query', + 'result_count', + ]; + /** * Build class. * @@ -63,6 +68,7 @@ public function __construct( $client = null ) { '404' => __( '404', 'plausible-analytics' ), 'outbound-links' => __( 'Outbound Link: Click', 'plausible-analytics' ), 'file-downloads' => __( 'File Download', 'plausible-analytics' ), + 'search' => __( 'Search', 'plausible-analytics' ), ]; $this->init(); @@ -140,6 +146,13 @@ public function maybe_create_goals( $old_settings, $settings ) { } $goals[] = $this->create_request_custom_event( $this->custom_event_goals[ $measurement ] ); + + if ( $measurement === 'search' ) { + global $wp_rewrite; + + $search_url = str_replace( '%search%', '', $wp_rewrite->get_search_permastruct() ); + $goals[] = $this->create_request_custom_event( null, 'Pageview', '', $search_url ); + } } $this->create_goals( $goals ); @@ -152,7 +165,7 @@ public function maybe_create_goals( $old_settings, $settings ) { * * @return GoalCreateRequestCustomEvent */ - private function create_request_custom_event( $name, $type = 'CustomEvent', $currency = '' ) { + private function create_request_custom_event( $name, $type = 'CustomEvent', $currency = '', $path = '' ) { $props = [ 'goal' => [ 'event_name' => $name, @@ -164,6 +177,12 @@ private function create_request_custom_event( $name, $type = 'CustomEvent', $cur $props[ 'goal' ][ 'currency' ] = $currency; } + if ( $type === 'Pageview' ) { + unset( $props[ 'goal' ][ 'event_name' ] ); + + $props[ 'goal' ][ 'path' ] = $path; + } + return new Client\Model\GoalCreateRequestCustomEvent( $props ); } @@ -267,7 +286,8 @@ public function maybe_create_custom_properties( $old_settings, $settings ) { $enhanced_measurements = $settings[ 'enhanced_measurements' ]; if ( ! Helpers::is_enhanced_measurement_enabled( 'pageview-props', $enhanced_measurements ) && - ! Helpers::is_enhanced_measurement_enabled( 'revenue', $enhanced_measurements ) ) { + ! Helpers::is_enhanced_measurement_enabled( 'revenue', $enhanced_measurements ) && + ! Helpers::is_enhanced_measurement_enabled( 'search', $enhanced_measurements ) ) { return; // @codeCoverageIgnore } @@ -292,6 +312,15 @@ public function maybe_create_custom_properties( $old_settings, $settings ) { } } + /** + * Create Custom Properties for Search Queries option. + */ + if ( Helpers::is_enhanced_measurement_enabled( 'search', $enhanced_measurements ) ) { + foreach ( $this->custom_search_properties as $property ) { + $properties[] = new Client\Model\CustomProp( [ 'custom_prop' => [ 'key' => $property ] ] ); + } + } + $create_request->setCustomProps( $properties ); $this->client->enable_custom_property( $create_request ); diff --git a/src/Admin/Settings/Page.php b/src/Admin/Settings/Page.php index de7a1cb9..bcfb35b0 100644 --- a/src/Admin/Settings/Page.php +++ b/src/Admin/Settings/Page.php @@ -153,6 +153,13 @@ public function __construct() { 'type' => 'checkbox', 'value' => 'file-downloads', ], + 'search' => [ + 'label' => esc_html__( 'Search queries', 'plausible-analytics' ), + 'docs' => 'https://plausible.io/wordpress-analytics-plugin#how-to-enable-site-search-tracking', + 'slug' => 'enhanced_measurements', + 'type' => 'checkbox', + 'value' => 'search', + ], 'tagged-events' => [ 'label' => esc_html__( 'Custom events', 'plausible-analytics' ), 'docs' => 'https://plausible.io/wordpress-analytics-plugin#how-to-setup-custom-events-to-track-goal-conversions', @@ -649,7 +656,7 @@ public function render_analytics_dashboard() {
+ loading="lazy" style="border: 0; width: 100%; height: 1750px; ">