DuracellTomi's Google Tag Manager for WordPress - Version 1.3.2

Version Description

  • Fixed: remove cart event not fired in WooCommerce 2.6
  • Fixed: ecomm_prodid.push error message on product detail pages
  • Fixed: proper tracking of cart actions on the cart page for WooCommerce 2.6
  • Fixed: 'Illegal string offset' errors in some cases in the cart
  • Fixed: OpenWeatherMap requires a (free) API key now, you can now enter this to use weather data in data layer
Download this release

Release Info

Developer duracelltomi
Plugin Icon 128x128 DuracellTomi's Google Tag Manager for WordPress
Version 1.3.2
Comparing to
See all releases

Code changes from version 1.3.1 to 1.3.2

admin/admin.php CHANGED
@@ -121,6 +121,11 @@ $GLOBALS["gtm4wp_includefieldtexts"] = array(
121
  "label" => __( "Weather data units", 'duracelltomi-google-tag-manager' ),
122
  "description" => __( "Select which temperature units you would like to use.", 'duracelltomi-google-tag-manager' ),
123
  "phase" => GTM4WP_PHASE_EXPERIMENTAL
 
 
 
 
 
124
  )
125
  );
126
 
@@ -1085,6 +1090,13 @@ function gtm4wp_add_plugin_action_links( $links, $file ) {
1085
  return $links;
1086
  }
1087
 
 
 
 
 
 
 
 
1088
  add_action( 'admin_init', 'gtm4wp_admin_init' );
1089
  add_action( 'admin_menu', 'gtm4wp_add_admin_page' );
1090
  add_action( 'admin_enqueue_scripts', 'gtm4wp_add_admin_js' );
@@ -1092,3 +1104,4 @@ add_action( 'admin_notices', 'gtm4wp_show_warning' );
1092
  add_action( 'admin_head', 'gtm4wp_admin_head' );
1093
  add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
1094
  add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
 
121
  "label" => __( "Weather data units", 'duracelltomi-google-tag-manager' ),
122
  "description" => __( "Select which temperature units you would like to use.", 'duracelltomi-google-tag-manager' ),
123
  "phase" => GTM4WP_PHASE_EXPERIMENTAL
124
+ ),
125
+ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
126
+ "label" => __( "OpenWeatherMap API key", 'duracelltomi-google-tag-manager' ),
127
+ "description" => __( 'Enter your OpenWeatherMap API key here. <a href="http://openweathermap.org/price" target="_blank">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ),
128
+ "phase" => GTM4WP_PHASE_EXPERIMENTAL
129
  )
130
  );
131
 
1090
  return $links;
1091
  }
1092
 
1093
+ function gtm4wp_show_upgrade_notification( $current_plugin_metadata, $new_plugin_metadata ) {
1094
+ if ( isset( $new_plugin_metadata->upgrade_notice ) && strlen( trim( $new_plugin_metadata->upgrade_notice ) ) > 0 ) {
1095
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>Important Upgrade Notice:</strong> ';
1096
+ echo esc_html($new_plugin_metadata->upgrade_notice), '</p>';
1097
+ }
1098
+ }
1099
+
1100
  add_action( 'admin_init', 'gtm4wp_admin_init' );
1101
  add_action( 'admin_menu', 'gtm4wp_add_admin_page' );
1102
  add_action( 'admin_enqueue_scripts', 'gtm4wp_add_admin_js' );
1104
  add_action( 'admin_head', 'gtm4wp_admin_head' );
1105
  add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
1106
  add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
1107
+ add_action( 'in_plugin_update_message-duracelltomi-google-tag-manager-for-wordpress/duracelltomi-google-tag-manager-for-wordpress.php', 'gtm4wp_show_upgrade_notification', 10, 2 );
common/readoptions.php CHANGED
@@ -21,7 +21,8 @@ define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
21
  define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
22
  define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
23
  define( 'GTM4WP_OPTION_INCLUDE_WEATHER', 'include-weather' );
24
- define( 'GTM4WP_OPTION_INCLUDE_WEATHERUNITS', 'include-weatherunits' );
 
25
 
26
  define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
27
  define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
@@ -94,24 +95,25 @@ $gtm4wp_defaultoptions = array(
94
  GTM4WP_OPTION_DATALAYER_NAME => "",
95
  GTM4WP_OPTION_GTM_PLACEMENT => GTM4WP_PLACEMENT_FOOTER,
96
 
97
- GTM4WP_OPTION_INCLUDE_REMARKETING => false,
98
- GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
99
- GTM4WP_OPTION_INCLUDE_USERROLE => false,
100
- GTM4WP_OPTION_INCLUDE_USERID => false,
101
- GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
102
- GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
103
- GTM4WP_OPTION_INCLUDE_TAGS => true,
104
- GTM4WP_OPTION_INCLUDE_AUTHOR => true,
105
- GTM4WP_OPTION_INCLUDE_POSTDATE => false,
106
- GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
107
- GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
108
- GTM4WP_OPTION_INCLUDE_POSTID => false,
109
- GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
110
- GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
111
- GTM4WP_OPTION_INCLUDE_OSDATA => false,
112
- GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
113
- GTM4WP_OPTION_INCLUDE_WEATHER => false,
114
- GTM4WP_OPTION_INCLUDE_WEATHERUNITS => 0,
 
115
 
116
  GTM4WP_OPTION_EVENTS_OUTBOUND => false,
117
  GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
21
  define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
22
  define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
23
  define( 'GTM4WP_OPTION_INCLUDE_WEATHER', 'include-weather' );
24
+ define( 'GTM4WP_OPTION_INCLUDE_WEATHERUNITS', 'weather-weatherunits' );
25
+ define( 'GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI', 'weather-openweathermap-apikey' );
26
 
27
  define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
28
  define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
95
  GTM4WP_OPTION_DATALAYER_NAME => "",
96
  GTM4WP_OPTION_GTM_PLACEMENT => GTM4WP_PLACEMENT_FOOTER,
97
 
98
+ GTM4WP_OPTION_INCLUDE_REMARKETING => false,
99
+ GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
100
+ GTM4WP_OPTION_INCLUDE_USERROLE => false,
101
+ GTM4WP_OPTION_INCLUDE_USERID => false,
102
+ GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
103
+ GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
104
+ GTM4WP_OPTION_INCLUDE_TAGS => true,
105
+ GTM4WP_OPTION_INCLUDE_AUTHOR => true,
106
+ GTM4WP_OPTION_INCLUDE_POSTDATE => false,
107
+ GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
108
+ GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
109
+ GTM4WP_OPTION_INCLUDE_POSTID => false,
110
+ GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
111
+ GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
112
+ GTM4WP_OPTION_INCLUDE_OSDATA => false,
113
+ GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
114
+ GTM4WP_OPTION_INCLUDE_WEATHER => false,
115
+ GTM4WP_OPTION_INCLUDE_WEATHERUNITS => 0,
116
+ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => '',
117
 
118
  GTM4WP_OPTION_EVENTS_OUTBOUND => false,
119
  GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
duracelltomi-google-tag-manager-for-wordpress.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Google Tag Manager for Wordpress
4
- Version: 1.3.1
5
  Plugin URI: https://duracelltomi.com/google-tag-manager-for-wordpress/
6
  Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
  Author: Thomas Geiger
@@ -10,7 +10,7 @@ Text Domain: duracelltomi-google-tag-manager
10
  Domain Path: /languages
11
  */
12
 
13
- define( 'GTM4WP_VERSION', '1.3.1' );
14
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
15
 
16
  $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
1
  <?php
2
  /*
3
  Plugin Name: Google Tag Manager for Wordpress
4
+ Version: 1.3.2
5
  Plugin URI: https://duracelltomi.com/google-tag-manager-for-wordpress/
6
  Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
  Author: Thomas Geiger
10
  Domain Path: /languages
11
  */
12
 
13
+ define( 'GTM4WP_VERSION', '1.3.2' );
14
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
15
 
16
  $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
integration/woocommerce.php CHANGED
@@ -109,13 +109,9 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
109
  } else if ( is_cart() ) {
110
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
111
  gtm4wp_woocommerce_addjs("
112
- $( '.product-quantity input' ).each(function() {
113
- $( this ).data( 'gtm4wp_original_value', $( this ).val() );
114
- });
115
-
116
- $( '[name=update_cart]' ).click( function() {
117
- $( '.product-quantity input' ).each(function() {
118
- var _original_value = $( this ).data( 'gtm4wp_original_value' );
119
 
120
  var _current_value = parseInt( $( this ).val() );
121
  if ( isNaN( _current_value ) ) {
@@ -160,8 +156,6 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
160
  }
161
  }
162
  });
163
-
164
- return false;
165
  });
166
  ");
167
  }
@@ -374,11 +368,11 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
374
 
375
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
376
  gtm4wp_woocommerce_addjs("
377
- $( '.shop_table.cart,.cart_list' ).on( 'click', '.mini_cart_item a.remove,.product-remove a.remove', function() {
378
  var productdata = $( this );
379
 
380
  var qty = 0;
381
- var qty_element = $( this ).closest( '.cart-item' ).find( '.product-quantity input.qty' );
382
  if ( 0 == qty_element.length ) {
383
  qty_element = $( this ).closest( '.mini_cart_item' ).find( '.quantity' );
384
  if ( qty_element.length > 0 ) {
@@ -502,6 +496,10 @@ function gtm4wp_woocommerce_wp_footer() {
502
  i = 0;
503
  ". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ] = [];
504
  }
 
 
 
 
505
 
506
  var productdata;
507
  $( '.gtm4wp_productdata' ).each( function() {
@@ -689,6 +687,14 @@ function gtm4wp_woocommerce_cart_item_product_filter($product) {
689
  }
690
 
691
  function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link ) {
 
 
 
 
 
 
 
 
692
  $cartlink_with_data = sprintf('data-gtm4wp_product_id="%s" data-gtm4wp_product_name="%s" data-gtm4wp_product_price="%s" data-gtm4wp_product_cat="%s" data-gtm4wp_product_url="%s" href="',
693
  esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["id"] ),
694
  esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["name"] ),
109
  } else if ( is_cart() ) {
110
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
111
  gtm4wp_woocommerce_addjs("
112
+ $( document ).on( 'click', '[name=update_cart]', function() {
113
+ $( '.product-quantity input.qty' ).each(function() {
114
+ var _original_value = $( this ).prop( 'defaultValue' );
 
 
 
 
115
 
116
  var _current_value = parseInt( $( this ).val() );
117
  if ( isNaN( _current_value ) ) {
156
  }
157
  }
158
  });
 
 
159
  });
160
  ");
161
  }
368
 
369
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
370
  gtm4wp_woocommerce_addjs("
371
+ $( document ).on( 'click', '.mini_cart_item a.remove,.product-remove a.remove', function() {
372
  var productdata = $( this );
373
 
374
  var qty = 0;
375
+ var qty_element = $( this ).closest( '.cart_item' ).find( '.product-quantity input.qty' );
376
  if ( 0 == qty_element.length ) {
377
  qty_element = $( this ).closest( '.mini_cart_item' ).find( '.quantity' );
378
  if ( qty_element.length > 0 ) {
496
  i = 0;
497
  ". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ] = [];
498
  }
499
+
500
+ if ( typeof ". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ].push == 'undefined' ) {
501
+ return false;
502
+ }
503
 
504
  var productdata;
505
  $( '.gtm4wp_productdata' ).each( function() {
687
  }
688
 
689
  function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link ) {
690
+ if ( ! isset( $GLOBALS["gtm4wp_cart_item_proddata"] ) ) {
691
+ return $remove_from_cart_link;
692
+ }
693
+
694
+ if ( ! is_array( $GLOBALS["gtm4wp_cart_item_proddata"] ) ) {
695
+ return $remove_from_cart_link;
696
+ }
697
+
698
  $cartlink_with_data = sprintf('data-gtm4wp_product_id="%s" data-gtm4wp_product_name="%s" data-gtm4wp_product_price="%s" data-gtm4wp_product_cat="%s" data-gtm4wp_product_url="%s" href="',
699
  esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["id"] ),
700
  esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["name"] ),
js/admin-subtabs.js CHANGED
@@ -24,7 +24,7 @@ var adminsubtabs = {
24
  },
25
  "weather": {
26
  tabtext: gtm4wp.weathertabtitle,
27
- numitems: 2
28
  }
29
  },
30
  2: {
24
  },
25
  "weather": {
26
  tabtext: gtm4wp.weathertabtitle,
27
+ numitems: 3
28
  }
29
  },
30
  2: {
public/frontend.php CHANGED
@@ -357,7 +357,7 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
357
  }
358
 
359
  function gtm4wp_wp_loaded() {
360
- global $gtm4wp_options;
361
 
362
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
363
  $gtm4wp_sessionid = array_key_exists( "gtm4wp_sessoionid", $_COOKIE ) ? $_COOKIE[ "gtm4wp_sessoionid" ] : "";
@@ -376,7 +376,7 @@ function gtm4wp_wp_loaded() {
376
  if ( $gtm4wp_geodata ) {
377
  $gtm4wp_geodata = unserialize( $gtm4wp_geodata );
378
  if ( array_key_exists( 'geoplugin_latitude', $gtm4wp_geodata ) && array_key_exists( 'geoplugin_longitude', $gtm4wp_geodata ) ) {
379
- $weatherdata = @file_get_contents('http://api.openweathermap.org/data/2.5/weather?lat=' . $gtm4wp_geodata[ "geoplugin_latitude" ] . '&lon=' . $gtm4wp_geodata[ "geoplugin_longitude" ] . '&units=' . ($gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'metric' : 'imperial'));
380
  if ( $weatherdata ) {
381
  $weatherdata = @json_decode( $weatherdata );
382
  if ( is_object( $weatherdata ) ) {
357
  }
358
 
359
  function gtm4wp_wp_loaded() {
360
+ global $gtm4wp_options;
361
 
362
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
363
  $gtm4wp_sessionid = array_key_exists( "gtm4wp_sessoionid", $_COOKIE ) ? $_COOKIE[ "gtm4wp_sessoionid" ] : "";
376
  if ( $gtm4wp_geodata ) {
377
  $gtm4wp_geodata = unserialize( $gtm4wp_geodata );
378
  if ( array_key_exists( 'geoplugin_latitude', $gtm4wp_geodata ) && array_key_exists( 'geoplugin_longitude', $gtm4wp_geodata ) ) {
379
+ $weatherdata = @file_get_contents('http://api.openweathermap.org/data/2.5/weather?appid=' . $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI ] . '&lat=' . $gtm4wp_geodata[ "geoplugin_latitude" ] . '&lon=' . $gtm4wp_geodata[ "geoplugin_longitude" ] . '&units=' . ($gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'metric' : 'imperial'));
380
  if ( $weatherdata ) {
381
  $weatherdata = @json_decode( $weatherdata );
382
  if ( is_object( $weatherdata ) ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://duracelltomi.com/
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.4.0
6
  Tested up to: 4.5.2
7
- Stable tag: 1.3.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -281,6 +281,14 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
281
 
282
  == Changelog ==
283
 
 
 
 
 
 
 
 
 
284
  = 1.3.1 =
285
 
286
  * Fixed: "json_encode() expects parameter 2 to be long, string given" on PHP 5.3 instances
@@ -437,6 +445,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
437
 
438
  == Upgrade Notice ==
439
 
 
 
 
 
440
  = 1.3.1 =
441
 
442
  Quickfix release for 1.3: major changes and improvements in the enhanced ecommerce implementation for WooCommerce. If you are already using this beta feature, please read the changelog before upgrading!
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.4.0
6
  Tested up to: 4.5.2
7
+ Stable tag: 1.3.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
281
 
282
  == Changelog ==
283
 
284
+ = 1.3.2 =
285
+
286
+ * Fixed: remove cart event not fired in WooCommerce 2.6
287
+ * Fixed: ecomm_prodid.push error message on product detail pages
288
+ * Fixed: proper tracking of cart actions on the cart page for WooCommerce 2.6
289
+ * Fixed: 'Illegal string offset' errors in some cases in the cart
290
+ * Fixed: OpenWeatherMap requires a (free) API key now, you can now enter this to use weather data in data layer
291
+
292
  = 1.3.1 =
293
 
294
  * Fixed: "json_encode() expects parameter 2 to be long, string given" on PHP 5.3 instances
445
 
446
  == Upgrade Notice ==
447
 
448
+ = 1.3.2 =
449
+
450
+ Quickfix release for 1.3.x: major changes and improvements in the enhanced ecommerce implementation for WooCommerce. If you are already using this beta feature, please read the changelog before upgrading!
451
+
452
  = 1.3.1 =
453
 
454
  Quickfix release for 1.3: major changes and improvements in the enhanced ecommerce implementation for WooCommerce. If you are already using this beta feature, please read the changelog before upgrading!