DuracellTomi's Google Tag Manager for WordPress - Version 1.11.6

Version Description

  • Fixed: do not track hidden products in the cart in WooCommerce shops
  • Fixed: do not fire add to cart event if button is in a disabled state
  • Fixed: fixed translation of an admin text
  • Fixed: needs_shipping_address() calls were sometimes broken in WooCommerce shops, added additional checks to prevent
  • Updated: removed the body_class method of adding the iframe/noscript container code (page builders and the standard wp_body_open hook remains supported)
Download this release

Release Info

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

Code changes from version 1.11.5 to 1.11.6

admin/admin.php CHANGED
@@ -822,7 +822,7 @@ function gtm4wp_admin_output_field( $args ) {
822
  if ( is_plugin_active( $args['plugintocheck'] ) ) {
823
  echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
824
  } else {
825
- echo '<br />' . __( 'This plugin (' . $args['plugintocheck'] . ') is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
826
  }
827
  }
828
 
822
  if ( is_plugin_active( $args['plugintocheck'] ) ) {
823
  echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
824
  } else {
825
+ sprintf( __( "This plugin (%s) is <strong class='gtm4wp-plugin-not-active'>not active</strong>, enabling this integration could cause issues on frontend!", "duracelltomi-google-tag-manager" ), $args['plugintocheck'] );
826
  }
827
  }
828
 
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.11.5
5
  Plugin URI: https://gtm4wp.com/
6
  Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
  Author: Thomas Geiger
@@ -10,10 +10,10 @@ Text Domain: duracelltomi-google-tag-manager
10
  Domain Path: /languages
11
 
12
  WC requires at least: 2.6
13
- WC tested up to: 4.4.0
14
  */
15
 
16
- define( 'GTM4WP_VERSION', '1.11.5' );
17
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
18
 
19
  global $gtp4wp_plugin_url, $gtp4wp_plugin_basename;
1
  <?php
2
  /*
3
  Plugin Name: Google Tag Manager for Wordpress
4
+ Version: 1.11.6
5
  Plugin URI: https://gtm4wp.com/
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
  WC requires at least: 2.6
13
+ WC tested up to: 4.7.0
14
  */
15
 
16
+ define( 'GTM4WP_VERSION', '1.11.6' );
17
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
18
 
19
  global $gtp4wp_plugin_url, $gtp4wp_plugin_basename;
integration/woocommerce.php CHANGED
@@ -210,6 +210,12 @@ function gtm4wp_process_order_items( $order ) {
210
 
211
  function gtm4wp_woocommerce_addglobalvars( $return = '' ) {
212
  global $gtm4wp_options;
 
 
 
 
 
 
213
 
214
  $return .= '
215
  var gtm4wp_use_sku_instead = ' . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) . ";
@@ -219,7 +225,7 @@ function gtm4wp_woocommerce_addglobalvars( $return = '' ) {
219
  var gtm4wp_classicec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) ) . ";
220
  var gtm4wp_currency = '" . esc_js( get_woocommerce_currency() ) . "';
221
  var gtm4wp_product_per_impression = " . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ] ) . ';
222
- var gtm4wp_needs_shipping_address = ' . gtm4wp_escjs_boolean( (bool) WC()->cart->needs_shipping_address() ) . ';';
223
 
224
  return $return;
225
  }
@@ -276,7 +282,10 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
276
 
277
  foreach( $current_cart->get_cart() as $cart_item_id => $cart_item_data) {
278
  $product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data["data"], $cart_item_data, $cart_item_id );
279
- if ( !apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
 
 
 
280
  continue;
281
  }
282
 
210
 
211
  function gtm4wp_woocommerce_addglobalvars( $return = '' ) {
212
  global $gtm4wp_options;
213
+
214
+ if ( function_exists( 'WC' ) && WC()->cart ) {
215
+ $gtm4wp_needs_shipping_address = (bool) WC()->cart->needs_shipping_address();
216
+ } else {
217
+ $gtm4wp_needs_shipping_address = false;
218
+ }
219
 
220
  $return .= '
221
  var gtm4wp_use_sku_instead = ' . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) . ";
225
  var gtm4wp_classicec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) ) . ";
226
  var gtm4wp_currency = '" . esc_js( get_woocommerce_currency() ) . "';
227
  var gtm4wp_product_per_impression = " . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ] ) . ';
228
+ var gtm4wp_needs_shipping_address = ' . gtm4wp_escjs_boolean( $gtm4wp_needs_shipping_address ) . ';';
229
 
230
  return $return;
231
  }
282
 
283
  foreach( $current_cart->get_cart() as $cart_item_id => $cart_item_data) {
284
  $product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data["data"], $cart_item_data, $cart_item_id );
285
+ if (
286
+ !apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data )
287
+ || !apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item_data, $cart_item_id )
288
+ ) {
289
  continue;
290
  }
291
 
js/gtm4wp-woocommerce-enhanced.js CHANGED
@@ -174,7 +174,7 @@ jQuery(function() {
174
  });
175
 
176
  // track add to cart events for products on product detail pages
177
- jQuery( document ).on( 'click', '.single_add_to_cart_button', function() {
178
  var _product_form = jQuery( this ).closest( 'form.cart' );
179
  var _product_var_id = jQuery( '[name=variation_id]', _product_form );
180
  var _product_is_grouped = jQuery( _product_form ).hasClass( 'grouped_form' );
174
  });
175
 
176
  // track add to cart events for products on product detail pages
177
+ jQuery( document ).on( 'click', '.single_add_to_cart_button:not(.disabled)', function() {
178
  var _product_form = jQuery( this ).closest( 'form.cart' );
179
  var _product_var_id = jQuery( '[name=variation_id]', _product_form );
180
  var _product_is_grouped = jQuery( _product_form ).hasClass( 'grouped_form' );
public/frontend.php CHANGED
@@ -967,18 +967,6 @@ j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
967
  }
968
  }
969
 
970
- function gtm4wp_body_class( $classes ) {
971
- global $gtm4wp_options;
972
-
973
- // solution is based on the code of Yaniv Friedensohn
974
- // http://www.affectivia.com/blog/placing-the-google-tag-manager-in-wordpress-after-the-body-tag/
975
- if ( ( GTM4WP_PLACEMENT_BODYOPEN_AUTO == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) && ( !isset($_GET["ct_builder"]) ) ) {
976
- $classes[] = '">' . gtm4wp_get_the_gtm_tag() . '<br style="display:none;';
977
- }
978
-
979
- return $classes;
980
- }
981
-
982
  function gtm4wp_wp_login() {
983
  setcookie( 'gtm4wp_user_logged_in', '1', 0, '/' );
984
  }
@@ -1010,7 +998,6 @@ add_action( 'wp_head', 'gtm4wp_wp_header_begin', $gtm4wp_header_begin_prior, 0 )
1010
  add_action( 'wp_head', 'gtm4wp_wp_header_top', 1, 0 );
1011
  add_action( 'wp_footer', 'gtm4wp_wp_footer' );
1012
  add_action( 'wp_loaded', 'gtm4wp_wp_loaded' );
1013
- add_filter( 'body_class', 'gtm4wp_body_class', 10000 );
1014
  add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, 'gtm4wp_add_basic_datalayer_data' );
1015
 
1016
  // to be able to easily migrate from other Google Tag Manager plugins
967
  }
968
  }
969
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  function gtm4wp_wp_login() {
971
  setcookie( 'gtm4wp_user_logged_in', '1', 0, '/' );
972
  }
998
  add_action( 'wp_head', 'gtm4wp_wp_header_top', 1, 0 );
999
  add_action( 'wp_footer', 'gtm4wp_wp_footer' );
1000
  add_action( 'wp_loaded', 'gtm4wp_wp_loaded' );
 
1001
  add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, 'gtm4wp_add_basic_datalayer_data' );
1002
 
1003
  // to be able to easily migrate from other Google Tag Manager plugins
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://gtm4wp.com/
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
- Tested up to: 5.5
8
- Stable tag: 1.11.5
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
@@ -258,6 +258,14 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
258
 
259
  == Changelog ==
260
 
 
 
 
 
 
 
 
 
261
  = 1.11.5 =
262
 
263
  * Fixed: new Google Optimize container ID format accepted now
@@ -670,6 +678,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
670
 
671
  == Upgrade Notice ==
672
 
 
 
 
 
673
  = 1.11.5 =
674
 
675
  Fixed: new Google Optimize container ID format accepted now
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
+ Tested up to: 5.6
8
+ Stable tag: 1.11.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
258
 
259
  == Changelog ==
260
 
261
+ = 1.11.6 =
262
+
263
+ * Fixed: do not track hidden products in the cart in WooCommerce shops
264
+ * Fixed: do not fire add to cart event if button is in a disabled state
265
+ * Fixed: fixed translation of an admin text
266
+ * Fixed: needs_shipping_address() calls were sometimes broken in WooCommerce shops, added additional checks to prevent
267
+ * Updated: removed the body_class method of adding the iframe/noscript container code (page builders and the standard wp_body_open hook remains supported)
268
+
269
  = 1.11.5 =
270
 
271
  * Fixed: new Google Optimize container ID format accepted now
678
 
679
  == Upgrade Notice ==
680
 
681
+ = 1.11.6 =
682
+
683
+ Bugfix release
684
+
685
  = 1.11.5 =
686
 
687
  Fixed: new Google Optimize container ID format accepted now