This commit is contained in:
Mik 2022-09-30 06:54:20 +01:00 committed by GitHub
parent 4a82b73baf
commit 6d5f4dbe7a
1 changed files with 4 additions and 2 deletions

View File

@ -46,9 +46,10 @@ class GoogleAnalytics {
*/
public function enqueue_scripts() {
$settings = $this->get_google_analytics_settings();
$prefix = strstr( strtoupper( $settings['ga_id'] ), '-', true );
// Require tracking to be enabled with a valid GA ID.
if ( ! stristr( $settings['ga_id'], 'G-' ) ) {
if ( ! in_array( $prefix, [ 'G', 'GT' ], true ) ) {
return;
}
@ -56,10 +57,11 @@ class GoogleAnalytics {
* Filter to disable Google Analytics tracking.
*
* @internal Matches filter name in GA extension.
* @since 4.9.0
*
* @param boolean $disable_tracking If true, tracking will be disabled.
*/
if ( ! stristr( $settings['ga_id'], 'G-' ) || apply_filters( 'woocommerce_ga_disable_tracking', ! wc_string_to_bool( $settings['ga_event_tracking_enabled'] ) ) ) {
if ( apply_filters( 'woocommerce_ga_disable_tracking', ! wc_string_to_bool( $settings['ga_event_tracking_enabled'] ) ) ) {
return;
}