WooCommerce Google Analytics Integration - Version 1.4.5

Version Description

  • 16/10/2018 =
  • Tweak - Mention Google Analytics Pro in certain cases.
  • Tweak - WC 3.5 compatibility.
Download this release

Release Info

Developer cshultz88
Plugin Icon 128x128 WooCommerce Google Analytics Integration
Version 1.4.5
Comparing to
See all releases

Code changes from version 1.4.4 to 1.4.5

includes/class-wc-google-analytics.php CHANGED
@@ -320,13 +320,18 @@ class WC_Google_Analytics extends WC_Integration {
320
* @param int $order_id
321
*/
322
protected function get_ecommerce_tracking_code( $order_id ) {
323
- // Get the order and output tracking code
324
- $order = new WC_Order( $order_id );
325
326
$code = WC_Google_Analytics_JS::get_instance()->load_analytics( $order );
327
$code .= WC_Google_Analytics_JS::get_instance()->add_transaction( $order );
328
329
- // Mark the order as tracked
330
update_post_meta( $order_id, '_ga_tracked', 1 );
331
332
return "
320
* @param int $order_id
321
*/
322
protected function get_ecommerce_tracking_code( $order_id ) {
323
+ // Get the order and output tracking code.
324
+ $order = wc_get_order( $order_id );
325
+
326
+ // Make sure we have a valid order object.
327
+ if ( ! $order ) {
328
+ return '';
329
+ }
330
331
$code = WC_Google_Analytics_JS::get_instance()->load_analytics( $order );
332
$code .= WC_Google_Analytics_JS::get_instance()->add_transaction( $order );
333
334
+ // Mark the order as tracked.
335
update_post_meta( $order_id, '_ga_tracked', 1 );
336
337
return "
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
=== WooCommerce Google Analytics Integration ===
2
- Contributors: woocommerce, claudiosanches, bor0, royho, laurendavissmith001
3
Tags: woocommerce, google analytics
4
Requires at least: 3.8
5
Tested up to: 4.9
6
- Stable tag: 1.4.4
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
@@ -68,6 +68,10 @@ Exact wording depends on the national data privacy laws and should be adjusted.
68
69
== Changelog ==
70
71
= 1.4.4 - 20/03/2018 =
72
* Fix - WC30 compatibility error when using deprecated get_product_from_item method.
73
* Fix - Check object before using methods to prevent errors.
1
=== WooCommerce Google Analytics Integration ===
2
+ Contributors: woocommerce, claudiosanches, bor0, royho, laurendavissmith001, c-shultz
3
Tags: woocommerce, google analytics
4
Requires at least: 3.8
5
Tested up to: 4.9
6
+ Stable tag: 1.4.5
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
68
69
== Changelog ==
70
71
+ = 1.4.5 - 16/10/2018 =
72
+ * Tweak - Mention Google Analytics Pro in certain cases.
73
+ * Tweak - WC 3.5 compatibility.
74
+
75
= 1.4.4 - 20/03/2018 =
76
* Fix - WC30 compatibility error when using deprecated get_product_from_item method.
77
* Fix - Check object before using methods to prevent errors.
woocommerce-google-analytics-integration.php CHANGED
@@ -5,9 +5,9 @@
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.4
9
* WC requires at least: 2.1
10
- * WC tested up to: 3.3
11
* License: GPLv2 or later
12
* Text Domain: woocommerce-google-analytics-integration
13
* Domain Path: languages/
@@ -29,7 +29,7 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
29
*
30
* @var string
31
*/
32
- const VERSION = '1.4.4';
33
34
/**
35
* Instance of this class.
@@ -41,9 +41,10 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
41
/**
42
* Initialize the plugin.
43
*/
44
- private function __construct() {
45
// Load plugin text domain
46
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
47
48
// Checks with WooCommerce is installed.
49
if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1-beta-1', '>=' ) ) {
@@ -122,6 +123,31 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
122
123
return $integrations;
124
}
125
}
126
127
add_action( 'plugins_loaded', array( 'WC_Google_Analytics_Integration', 'get_instance' ), 0 );
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.5
9
* WC requires at least: 2.1
10
+ * WC tested up to: 3.5
11
* License: GPLv2 or later
12
* Text Domain: woocommerce-google-analytics-integration
13
* Domain Path: languages/
29
*
30
* @var string
31
*/
32
+ const VERSION = '1.4.5';
33
34
/**
35
* Instance of this class.
41
/**
42
* Initialize the plugin.
43
*/
44
+ public function __construct() {
45
// Load plugin text domain
46
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
47
+ add_action( 'init', array( $this, 'show_ga_pro_notices' ) );
48
49
// Checks with WooCommerce is installed.
50
if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1-beta-1', '>=' ) ) {
123
124
return $integrations;
125
}
126
+
127
+ /**
128
+ * Logic for Google Analytics Pro notices.
129
+ */
130
+ public function show_ga_pro_notices() {
131
+ // Notice was already shown
132
+ if ( get_option( 'woocommerce_google_analytics_pro_notice_shown', false ) ) {
133
+ return;
134
+ }
135
+
136
+ $completed_orders = wc_orders_count( 'completed' );
137
+
138
+ // Only show the notice if there are 10 <= completed orders <= 100.
139
+ if ( ! ( 10 <= $completed_orders && $completed_orders <= 100 ) ) {
140
+ return;
141
+ }
142
+
143
+ $notice_html = '<strong>' . esc_html__( 'Get detailed insights into your sales with Google Analytics Pro', 'woocommerce-google-analytics-integration' ) . '</strong><br><br>';
144
+
145
+ /* translators: 1: href link to GA pro */
146
+ $notice_html .= sprintf( __( 'Add advanced tracking for your sales funnel, coupons and more. [<a href="%s" target="_blank">Learn more</a> &gt;]', 'woocommerce-google-analytics-integration' ), 'https://woocommerce.com/products/woocommerce-google-analytics-pro/?utm_source=product&utm_medium=upsell&utm_campaign=google%20analytics%20free%20to%20pro%20extension%20upsell' );
147
+
148
+ WC_Admin_Notices::add_custom_notice( 'woocommerce_google_analytics_pro_notice', $notice_html );
149
+ update_option( 'woocommerce_google_analytics_pro_notice_shown', true );
150
+ }
151
}
152
153
add_action( 'plugins_loaded', array( 'WC_Google_Analytics_Integration', 'get_instance' ), 0 );