Load google analytics gtag script asynchronously in WooCommerce Blocks (#43040)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
0c5d01a6ac
commit
db17f27f02
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: performance
|
||||
|
||||
Load the gtag script used by Google Analytics asynchronously in WooCommerce Blocks.
|
|
@ -69,8 +69,19 @@ class GoogleAnalytics {
|
|||
}
|
||||
|
||||
if ( ! wp_script_is( 'google-tag-manager', 'registered' ) ) {
|
||||
// Using an array with strategies as the final argument to wp_register_script was introduced in WP 6.3.
|
||||
// WC requires at least 6.3 at the point of adding this, so it's safe to leave in without version checks.
|
||||
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
|
||||
wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'], [], null, false );
|
||||
wp_register_script(
|
||||
'google-tag-manager',
|
||||
'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'],
|
||||
[],
|
||||
null,
|
||||
[
|
||||
'in_footer' => false,
|
||||
'strategy' => 'async',
|
||||
]
|
||||
);
|
||||
wp_add_inline_script(
|
||||
'google-tag-manager',
|
||||
"
|
||||
|
|
Loading…
Reference in New Issue