WooCommerce Google Analytics Integration - Version 1.4.3

Version Description

  • 15/06/2017 =
  • Fix - WC 3.x notice by using proper variation data.
  • Add - Option to track 404 (Not found) errors.
Download this release

Release Info

Developer bor0
Plugin Icon 128x128 WooCommerce Google Analytics Integration
Version 1.4.3
Comparing to
See all releases

Code changes from version 1.4.2 to 1.4.3

includes/class-wc-google-analytics-js.php CHANGED
@@ -92,6 +92,13 @@ class WC_Google_Analytics_JS {
92
  $anonymize_enabled = "['_gat._anonymizeIp'],";
93
  }
94
 
 
 
 
 
 
 
 
95
  $domainname = self::get( 'ga_set_domain_name' );
96
 
97
  if ( ! empty( $domainname ) ) {
@@ -103,7 +110,8 @@ class WC_Google_Analytics_JS {
103
  $code = "var _gaq = _gaq || [];
104
  _gaq.push(
105
  ['_setAccount', '" . esc_js( self::get( 'ga_id' ) ) . "'], " . $set_domain_name .
106
- $anonymize_enabled . "
 
107
  ['_setCustomVar', 1, 'logged-in', '" . esc_js( $logged_in ) . "', 1],
108
  ['_trackPageview']";
109
 
@@ -226,6 +234,12 @@ class WC_Google_Analytics_JS {
226
  $anonymize_enabled = "" . self::tracker_var() . "( 'set', 'anonymizeIp', true );";
227
  }
228
 
 
 
 
 
 
 
229
  $ga_snippet_head = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
230
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
231
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@@ -237,7 +251,8 @@ class WC_Google_Analytics_JS {
237
  $ga_snippet_require =
238
  $support_display_advertising .
239
  $support_enhanced_link_attribution .
240
- $anonymize_enabled . "
 
241
  " . self::tracker_var() . "( 'set', 'dimension1', '" . $logged_in . "' );\n";
242
 
243
  if ( 'yes' === self::get( 'ga_enhanced_ecommerce_tracking_enabled' ) ) {
@@ -418,7 +433,7 @@ class WC_Google_Analytics_JS {
418
  private static function product_get_category_line( $_product ) {
419
  $variation_data = version_compare( WC_VERSION, '3.0', '<' ) ? $_product->variation_data : ( $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : '' );
420
  if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
421
- $code = "'" . esc_js( wc_get_formatted_variation( $_product->variation_data, true ) ) . "',";
422
  } else {
423
  $out = array();
424
  $categories = get_the_terms( $_product->get_id(), 'product_cat' );
92
  $anonymize_enabled = "['_gat._anonymizeIp'],";
93
  }
94
 
95
+ $track_404_enabled = '';
96
+ if ( 'yes' === self::get( 'ga_404_tracking_enabled' ) && is_404() ) {
97
+ // See https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking#_trackevent
98
+ $track_404_enabled = "['_trackEvent', 'Error', '404 Not Found', 'page: ' + document.location.pathname + document.location.search + ' referrer: ' + document.referrer ],";
99
+ }
100
+
101
+
102
  $domainname = self::get( 'ga_set_domain_name' );
103
 
104
  if ( ! empty( $domainname ) ) {
110
  $code = "var _gaq = _gaq || [];
111
  _gaq.push(
112
  ['_setAccount', '" . esc_js( self::get( 'ga_id' ) ) . "'], " . $set_domain_name .
113
+ $anonymize_enabled .
114
+ $track_404_enabled . "
115
  ['_setCustomVar', 1, 'logged-in', '" . esc_js( $logged_in ) . "', 1],
116
  ['_trackPageview']";
117
 
234
  $anonymize_enabled = "" . self::tracker_var() . "( 'set', 'anonymizeIp', true );";
235
  }
236
 
237
+ $track_404_enabled = '';
238
+ if ( 'yes' === self::get( 'ga_404_tracking_enabled' ) && is_404() ) {
239
+ // See https://developers.google.com/analytics/devguides/collection/analyticsjs/events for reference
240
+ $track_404_enabled = "" . self::tracker_var() . "( 'send', 'event', 'Error', '404 Not Found', 'page: ' + document.location.pathname + document.location.search + ' referrer: ' + document.referrer );";
241
+ }
242
+
243
  $ga_snippet_head = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
244
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
245
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
251
  $ga_snippet_require =
252
  $support_display_advertising .
253
  $support_enhanced_link_attribution .
254
+ $anonymize_enabled .
255
+ $track_404_enabled . "
256
  " . self::tracker_var() . "( 'set', 'dimension1', '" . $logged_in . "' );\n";
257
 
258
  if ( 'yes' === self::get( 'ga_enhanced_ecommerce_tracking_enabled' ) ) {
433
  private static function product_get_category_line( $_product ) {
434
  $variation_data = version_compare( WC_VERSION, '3.0', '<' ) ? $_product->variation_data : ( $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : '' );
435
  if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
436
+ $code = "'" . esc_js( wc_get_formatted_variation( $variation_data, true ) ) . "',";
437
  } else {
438
  $out = array();
439
  $categories = get_the_terms( $_product->get_id(), 'product_cat' );
includes/class-wc-google-analytics.php CHANGED
@@ -76,6 +76,7 @@ class WC_Google_Analytics extends WC_Integration {
76
  'ga_support_enhanced_link_attribution',
77
  'ga_use_universal_analytics',
78
  'ga_anonymize_enabled',
 
79
  'ga_ecommerce_tracking_enabled',
80
  'ga_enhanced_ecommerce_tracking_enabled',
81
  'ga_enhanced_remove_from_cart_enabled',
@@ -148,6 +149,13 @@ class WC_Google_Analytics extends WC_Integration {
148
  'checkboxgroup' => '',
149
  'default' => 'yes'
150
  ),
 
 
 
 
 
 
 
151
  'ga_ecommerce_tracking_enabled' => array(
152
  'label' => __( 'Purchase Transactions', 'woocommerce-google-analytics-integration' ),
153
  'description' => __( 'This requires a payment gateway that redirects to the thank you/order received page after payment. Orders paid with gateways which do not do this will not be tracked.', 'woocommerce-google-analytics-integration' ),
@@ -238,6 +246,7 @@ class WC_Google_Analytics extends WC_Integration {
238
  'support_enhanced_link_attribution' => $this->ga_support_enhanced_link_attribution,
239
  'use_universal_analytics' => $this->ga_use_universal_analytics,
240
  'anonymize_enabled' => $this->ga_anonymize_enabled,
 
241
  'ecommerce_tracking_enabled' => $this->ga_ecommerce_tracking_enabled,
242
  'event_tracking_enabled' => $this->ga_event_tracking_enabled
243
  );
76
  'ga_support_enhanced_link_attribution',
77
  'ga_use_universal_analytics',
78
  'ga_anonymize_enabled',
79
+ 'ga_404_tracking_enabled',
80
  'ga_ecommerce_tracking_enabled',
81
  'ga_enhanced_ecommerce_tracking_enabled',
82
  'ga_enhanced_remove_from_cart_enabled',
149
  'checkboxgroup' => '',
150
  'default' => 'yes'
151
  ),
152
+ 'ga_404_tracking_enabled' => array(
153
+ 'label' => __( 'Track 404 (Not found) Errors.', 'woocommerce-google-analytics-integration' ),
154
+ 'description' => sprintf( __( 'Enable this to find broken or dead links. An "Event" with category "Error" and action "404 Not Found" will be created in Google Analytics for each incoming pageview to a non-existing page. By setting up a "Custom Goal" for these events within Google Analytics you can find out where broken links originated from (the referrer). %sRead how to set up a goal%s.', 'woocommerce-google-analytics-integration' ), '<a href="https://support.google.com/analytics/answer/1032415" target="_blank">', '</a>' ),
155
+ 'type' => 'checkbox',
156
+ 'checkboxgroup' => '',
157
+ 'default' => 'yes'
158
+ ),
159
  'ga_ecommerce_tracking_enabled' => array(
160
  'label' => __( 'Purchase Transactions', 'woocommerce-google-analytics-integration' ),
161
  'description' => __( 'This requires a payment gateway that redirects to the thank you/order received page after payment. Orders paid with gateways which do not do this will not be tracked.', 'woocommerce-google-analytics-integration' ),
246
  'support_enhanced_link_attribution' => $this->ga_support_enhanced_link_attribution,
247
  'use_universal_analytics' => $this->ga_use_universal_analytics,
248
  'anonymize_enabled' => $this->ga_anonymize_enabled,
249
+ 'ga_404_tracking_enabled' => $this->ga_404_tracking_enabled,
250
  'ecommerce_tracking_enabled' => $this->ga_ecommerce_tracking_enabled,
251
  'event_tracking_enabled' => $this->ga_event_tracking_enabled
252
  );
package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "woocommerce-google-analytics-integration",
3
  "title": "WooCommerce Google Analytics Integration",
4
- "version": "1.4.2",
5
  "homepage": "https://wordpress.org/plugins/woocommerce-google-analytics-integration/",
6
  "repository": {
7
  "type": "git",
1
  {
2
  "name": "woocommerce-google-analytics-integration",
3
  "title": "WooCommerce Google Analytics Integration",
4
+ "version": "1.4.3",
5
  "homepage": "https://wordpress.org/plugins/woocommerce-google-analytics-integration/",
6
  "repository": {
7
  "type": "git",
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: woothemes, claudiosanches, bor0
3
  Tags: woocommerce, google analytics
4
  Requires at least: 3.8
5
  Tested up to: 4.5.2
6
- Stable tag: 1.4.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -64,6 +64,10 @@ Exact wording depends on the national data privacy laws and should be adjusted.
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 1.4.2 - 09/05/2017 =
68
  * Fix - Missing Google Analytics ID.
69
 
3
  Tags: woocommerce, google analytics
4
  Requires at least: 3.8
5
  Tested up to: 4.5.2
6
+ Stable tag: 1.4.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
64
 
65
  == Changelog ==
66
 
67
+ = 1.4.3 - 15/06/2017 =
68
+ * Fix - WC 3.x notice by using proper variation data.
69
+ * Add - Option to track 404 (Not found) errors.
70
+
71
  = 1.4.2 - 09/05/2017 =
72
  * Fix - Missing Google Analytics ID.
73
 
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.4.2
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-google-analytics-integration
11
  * Domain Path: languages/
@@ -27,7 +27,7 @@ class WC_Google_Analytics_Integration {
27
  *
28
  * @var string
29
  */
30
- const VERSION = '1.4.2';
31
 
32
  /**
33
  * Instance of this class.
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.4.3
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-google-analytics-integration
11
  * Domain Path: languages/
27
  *
28
  * @var string
29
  */
30
+ const VERSION = '1.4.3';
31
 
32
  /**
33
  * Instance of this class.