Support a GT tracking ID (https://github.com/woocommerce/woocommerce-blocks/pull/7213)
This commit is contained in:
parent
4a82b73baf
commit
6d5f4dbe7a
|
@ -46,9 +46,10 @@ class GoogleAnalytics {
|
||||||
*/
|
*/
|
||||||
public function enqueue_scripts() {
|
public function enqueue_scripts() {
|
||||||
$settings = $this->get_google_analytics_settings();
|
$settings = $this->get_google_analytics_settings();
|
||||||
|
$prefix = strstr( strtoupper( $settings['ga_id'] ), '-', true );
|
||||||
|
|
||||||
// Require tracking to be enabled with a valid GA ID.
|
// Require tracking to be enabled with a valid GA ID.
|
||||||
if ( ! stristr( $settings['ga_id'], 'G-' ) ) {
|
if ( ! in_array( $prefix, [ 'G', 'GT' ], true ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +57,11 @@ class GoogleAnalytics {
|
||||||
* Filter to disable Google Analytics tracking.
|
* Filter to disable Google Analytics tracking.
|
||||||
*
|
*
|
||||||
* @internal Matches filter name in GA extension.
|
* @internal Matches filter name in GA extension.
|
||||||
|
* @since 4.9.0
|
||||||
*
|
*
|
||||||
* @param boolean $disable_tracking If true, tracking will be disabled.
|
* @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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue