WooCommerce Google Analytics Integration - Version 1.5.8

Version Description

  • 2022-02-02 =
  • Add - Support for Google Analytics cross domain tracking features.
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce Google Analytics Integration
Version 1.5.8
Comparing to
See all releases

Code changes from version 1.5.7 to 1.5.8

assets/js/admin-ga-settings.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(n){var o=n("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled"),g=n("#woocommerce_google_analytics_ga_use_universal_analytics"),t=n("#woocommerce_google_analytics_ga_gtag_enabled");function e(){var e=o.is(":checked"),c=g.is(":checked"),a=t.is(":checked");_(n(".legacy-setting"),!a),_(n(".enhanced-setting"),e&&(c||a)),_(o,c||a),_(g,!a)}function _(e,c){c?e.closest("tr").show():e.closest("tr").hide()}e(),o.change(e),g.change(e),t.change(e)});
changelog.txt CHANGED
@@ -1,5 +1,8 @@
1
  *** Changelog ***
2
 
 
 
 
3
  = 1.5.7 - 2022-01-13 =
4
  * Fix - Activation error when WC was disabled.
5
  * Tweak - WC 6.1 compatibility.
1
  *** Changelog ***
2
 
3
+ = 1.5.8 - 2022-02-02 =
4
+ * Add - Support for Google Analytics cross domain tracking features.
5
+
6
  = 1.5.7 - 2022-01-13 =
7
  * Fix - Activation error when WC was disabled.
8
  * Tweak - WC 6.1 compatibility.
includes/class-wc-google-analytics-js.php CHANGED
@@ -243,7 +243,12 @@ class WC_Google_Analytics_JS extends WC_Abstract_Google_Analytics_JS {
243
  })(window,document,'script', '{$src}','" . self::tracker_var() . "');";
244
 
245
  $ga_id = self::get( 'ga_id' );
246
- $ga_snippet_create = self::tracker_var() . "( 'create', '" . esc_js( $ga_id ) . "', '" . $set_domain_name . "' );";
 
 
 
 
 
247
 
248
  if ( ! empty( self::DEVELOPER_ID ) ) {
249
  $ga_snippet_developer_id = "(window.gaDevIds=window.gaDevIds||[]).push('" . self::DEVELOPER_ID . "');";
@@ -263,6 +268,13 @@ class WC_Google_Analytics_JS extends WC_Abstract_Google_Analytics_JS {
263
  $ga_snippet_require .= "" . self::tracker_var() . "( 'require', 'ecommerce', 'ecommerce.js');";
264
  }
265
 
 
 
 
 
 
 
 
266
  $ga_snippet_head = apply_filters( 'woocommerce_ga_snippet_head', $ga_snippet_head );
267
  $ga_snippet_create = apply_filters( 'woocommerce_ga_snippet_create', $ga_snippet_create, $ga_id );
268
  $ga_snippet_developer_id = apply_filters( 'woocommerce_ga_snippet_developer_id', $ga_snippet_developer_id );
243
  })(window,document,'script', '{$src}','" . self::tracker_var() . "');";
244
 
245
  $ga_id = self::get( 'ga_id' );
246
+
247
+ if ( 'yes' === self::get( 'ga_linker_allow_incoming_enabled' ) ) {
248
+ $ga_snippet_create = self::tracker_var() . "( 'create', '" . esc_js( $ga_id ) . "', '" . $set_domain_name . "', { allowLinker: true });";
249
+ } else {
250
+ $ga_snippet_create = self::tracker_var() . "( 'create', '" . esc_js( $ga_id ) . "', '" . $set_domain_name . "' );";
251
+ }
252
 
253
  if ( ! empty( self::DEVELOPER_ID ) ) {
254
  $ga_snippet_developer_id = "(window.gaDevIds=window.gaDevIds||[]).push('" . self::DEVELOPER_ID . "');";
268
  $ga_snippet_require .= "" . self::tracker_var() . "( 'require', 'ecommerce', 'ecommerce.js');";
269
  }
270
 
271
+ $ga_cross_domains = ! empty( self::get( 'ga_linker_cross_domains' ) ) ? array_map( 'esc_js', explode( ',', self::get( 'ga_linker_cross_domains' ) ) ) : false;
272
+
273
+ if ( $ga_cross_domains ) {
274
+ $ga_snippet_require .= '' . self::tracker_var() . "( 'require', 'linker' );";
275
+ $ga_snippet_require .= '' . self::tracker_var() . "( 'linker:autoLink', " . wp_json_encode( $ga_cross_domains ) . ');';
276
+ }
277
+
278
  $ga_snippet_head = apply_filters( 'woocommerce_ga_snippet_head', $ga_snippet_head );
279
  $ga_snippet_create = apply_filters( 'woocommerce_ga_snippet_create', $ga_snippet_create, $ga_id );
280
  $ga_snippet_developer_id = apply_filters( 'woocommerce_ga_snippet_developer_id', $ga_snippet_developer_id );
includes/class-wc-google-analytics.php CHANGED
@@ -28,6 +28,8 @@ if ( ! defined( 'ABSPATH' ) ) {
28
  * @property $ga_enhanced_checkout_process_enabled
29
  * @property $ga_enhanced_product_detail_view_enabled
30
  * @property $ga_event_tracking_enabled
 
 
31
  */
32
  class WC_Google_Analytics extends WC_Integration {
33
 
@@ -120,6 +122,8 @@ class WC_Google_Analytics extends WC_Integration {
120
  'ga_enhanced_checkout_process_enabled',
121
  'ga_enhanced_product_detail_view_enabled',
122
  'ga_event_tracking_enabled',
 
 
123
  );
124
 
125
  $constructor = array();
@@ -224,7 +228,21 @@ class WC_Google_Analytics extends WC_Integration {
224
  'checkboxgroup' => '',
225
  'default' => 'yes',
226
  ),
227
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  'ga_enhanced_ecommerce_tracking_enabled' => array(
229
  'title' => __( 'Enhanced eCommerce', 'woocommerce-google-analytics-integration' ),
230
  'label' => __( 'Enable Enhanced eCommerce ', 'woocommerce-google-analytics-integration' ),
@@ -235,6 +253,7 @@ class WC_Google_Analytics extends WC_Integration {
235
  'class' => 'legacy-setting'
236
  ),
237
 
 
238
  // Enhanced eCommerce Sub-Settings
239
 
240
  'ga_enhanced_remove_from_cart_enabled' => array(
@@ -312,6 +331,8 @@ class WC_Google_Analytics extends WC_Integration {
312
  'set_domain_name' => empty( $this->ga_set_domain_name ) ? 'no' : 'yes',
313
  'plugin_version' => WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION,
314
  'enhanced_ecommerce_tracking_enabled' => $this->ga_enhanced_ecommerce_tracking_enabled,
 
 
315
  );
316
 
317
  // ID prefix, blank, or X for unknown
28
  * @property $ga_enhanced_checkout_process_enabled
29
  * @property $ga_enhanced_product_detail_view_enabled
30
  * @property $ga_event_tracking_enabled
31
+ * @property $ga_linker_cross_domains
32
+ * @property $ga_linker_allow_incoming_enabled
33
  */
34
  class WC_Google_Analytics extends WC_Integration {
35
 
122
  'ga_enhanced_checkout_process_enabled',
123
  'ga_enhanced_product_detail_view_enabled',
124
  'ga_event_tracking_enabled',
125
+ 'ga_linker_cross_domains',
126
+ 'ga_linker_allow_incoming_enabled',
127
  );
128
 
129
  $constructor = array();
228
  'checkboxgroup' => '',
229
  'default' => 'yes',
230
  ),
231
+ 'ga_linker_cross_domains' => array(
232
+ 'title' => __( 'Cross Domain Tracking', 'woocommerce-google-analytics-integration' ),
233
+ /* translators: Read more link */
234
+ 'description' => sprintf( __( 'Add a comma separated list of domains for automatic linking. %1$sRead more about Cross Domain Measurement%2$s', 'woocommerce-google-analytics-integration' ), '<a href="https://support.google.com/analytics/answer/7476333" target="_blank">', '</a>' ),
235
+ 'type' => 'text',
236
+ 'placeholder' => 'example.com, example.net',
237
+ 'default' => '',
238
+ ),
239
+ 'ga_linker_allow_incoming_enabled' => array(
240
+ 'label' => __( 'Accept Incoming Linker Parameters', 'woocommerce-google-analytics-integration' ),
241
+ 'description' => __( 'Enabling this option will allow incoming linker parameters from other websites.', 'woocommerce-google-analytics-integration' ),
242
+ 'type' => 'checkbox',
243
+ 'checkboxgroup' => '',
244
+ 'default' => 'no',
245
+ ),
246
  'ga_enhanced_ecommerce_tracking_enabled' => array(
247
  'title' => __( 'Enhanced eCommerce', 'woocommerce-google-analytics-integration' ),
248
  'label' => __( 'Enable Enhanced eCommerce ', 'woocommerce-google-analytics-integration' ),
253
  'class' => 'legacy-setting'
254
  ),
255
 
256
+
257
  // Enhanced eCommerce Sub-Settings
258
 
259
  'ga_enhanced_remove_from_cart_enabled' => array(
331
  'set_domain_name' => empty( $this->ga_set_domain_name ) ? 'no' : 'yes',
332
  'plugin_version' => WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION,
333
  'enhanced_ecommerce_tracking_enabled' => $this->ga_enhanced_ecommerce_tracking_enabled,
334
+ 'linker_allow_incoming_enabled' => empty( $this->ga_linker_allow_incoming_enabled ) ? 'no' : 'yes',
335
+ 'linker_cross_domains' => $this->ga_linker_cross_domains,
336
  );
337
 
338
  // ID prefix, blank, or X for unknown
includes/class-wc-google-gtag-js.php CHANGED
@@ -114,7 +114,9 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
114
  $gtag_developer_id = "gtag('set', 'developer_id." . self::DEVELOPER_ID . "', true);";
115
  }
116
 
117
- $gtag_id = self::get( 'ga_id' );
 
 
118
  $gtag_snippet = '<script async src="https://www.googletagmanager.com/gtag/js?id=' . esc_js( $gtag_id ) . '"></script>';
119
  $gtag_snippet .= "
120
  <script>
@@ -127,6 +129,10 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
127
  'allow_google_signals': " . ( 'yes' === self::get( 'ga_support_display_advertising' ) ? 'true' : 'false' ) . ",
128
  'link_attribution': " . ( 'yes' === self::get( 'ga_support_enhanced_link_attribution' ) ? 'true' : 'false' ) . ",
129
  'anonymize_ip': " . ( 'yes' === self::get( 'ga_anonymize_enabled' ) ? 'true' : 'false' ) . ",
 
 
 
 
130
  'custom_map': {
131
  'dimension1': 'logged_in'
132
  },
114
  $gtag_developer_id = "gtag('set', 'developer_id." . self::DEVELOPER_ID . "', true);";
115
  }
116
 
117
+ $gtag_id = self::get( 'ga_id' );
118
+ $gtag_cross_domains = ! empty( self::get( 'ga_linker_cross_domains' ) ) ? array_map( 'esc_js', explode( ',', self::get( 'ga_linker_cross_domains' ) ) ) : array();
119
+
120
  $gtag_snippet = '<script async src="https://www.googletagmanager.com/gtag/js?id=' . esc_js( $gtag_id ) . '"></script>';
121
  $gtag_snippet .= "
122
  <script>
129
  'allow_google_signals': " . ( 'yes' === self::get( 'ga_support_display_advertising' ) ? 'true' : 'false' ) . ",
130
  'link_attribution': " . ( 'yes' === self::get( 'ga_support_enhanced_link_attribution' ) ? 'true' : 'false' ) . ",
131
  'anonymize_ip': " . ( 'yes' === self::get( 'ga_anonymize_enabled' ) ? 'true' : 'false' ) . ",
132
+ 'linker':{
133
+ 'domains': " . wp_json_encode( $gtag_cross_domains ) . ",
134
+ 'allow_incoming': " . ( 'yes' === self::get( 'ga_linker_allow_incoming_enabled' ) ? 'true' : 'false' ) . ",
135
+ },
136
  'custom_map': {
137
  'dimension1': 'logged_in'
138
  },
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: woocommerce, automattic, claudiosanches, bor0, royho, laurendaviss
3
  Tags: woocommerce, google analytics
4
  Requires at least: 3.9
5
  Tested up to: 5.9
6
- Stable tag: 1.5.7
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -60,6 +60,9 @@ Exact wording depends on the national data privacy laws and should be adjusted.
60
 
61
  == Changelog ==
62
 
 
 
 
63
  = 1.5.7 - 2022-01-13 =
64
  * Fix - Activation error when WC was disabled.
65
  * Tweak - WC 6.1 compatibility.
3
  Tags: woocommerce, google analytics
4
  Requires at least: 3.9
5
  Tested up to: 5.9
6
+ Stable tag: 1.5.8
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
60
 
61
  == Changelog ==
62
 
63
+ = 1.5.8 - 2022-02-02 =
64
+ * Add - Support for Google Analytics cross domain tracking features.
65
+
66
  = 1.5.7 - 2022-01-13 =
67
  * Fix - Activation error when WC was disabled.
68
  * Tweak - WC 6.1 compatibility.
woocommerce-google-analytics-integration.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
6
  * Author: WooCommerce
7
  * Author URI: https://woocommerce.com
8
- * Version: 1.5.7
9
  * WC requires at least: 3.2
10
  * WC tested up to: 6.1
11
  * Tested up to: 5.9
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
20
 
21
  if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
22
 
23
- define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.7' ); // WRCS: DEFINED_VERSION.
24
 
25
  // Maybe show the GA Pro notice on plugin activation.
26
  register_activation_hook(
5
  * Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
6
  * Author: WooCommerce
7
  * Author URI: https://woocommerce.com
8
+ * Version: 1.5.8
9
  * WC requires at least: 3.2
10
  * WC tested up to: 6.1
11
  * Tested up to: 5.9
20
 
21
  if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
22
 
23
+ define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.8' ); // WRCS: DEFINED_VERSION.
24
 
25
  // Maybe show the GA Pro notice on plugin activation.
26
  register_activation_hook(