DuracellTomi's Google Tag Manager for WordPress - Version 1.11.4

Version Description

  • Fixed: fire gtm4wp.checkoutStepEEC and gtm4wp.checkoutOptionEEC events if there is only one shipping method available and it is hidden from the user
  • Fixed: decrease checkout step numbers 3 and 4 if shipping destination is set to 'Force shipping to the customer billing address' in WooCommerce. This way there will be no gap in Checkout behaviour report in Google Analytics.
  • Updated: tested version number for WooCommerce
Download this release

Release Info

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

Code changes from version 1.11.3 to 1.11.4

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.3
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: 3.9.3
14
  */
15
 
16
- define( 'GTM4WP_VERSION', '1.11.3' );
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.4
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.0.0
14
  */
15
 
16
+ define( 'GTM4WP_VERSION', '1.11.4' );
17
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
18
 
19
  global $gtp4wp_plugin_url, $gtp4wp_plugin_basename;
integration/woocommerce.php CHANGED
@@ -218,7 +218,8 @@ function gtm4wp_woocommerce_addglobalvars( $return = '' ) {
218
  var gtm4wp_eec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) . ';
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
 
223
  return $return;
224
  }
218
  var gtm4wp_eec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) . ';
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
  }
js/gtm4wp-woocommerce-enhanced.js CHANGED
@@ -472,6 +472,7 @@ jQuery(function() {
472
  if ( is_checkout ) {
473
  window.gtm4wp_checkout_step_offset = window.gtm4wp_checkout_step_offset || 0;
474
  window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || [];
 
475
  var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
476
 
477
  jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name^=shipping_method])', function() {
@@ -516,7 +517,7 @@ jQuery(function() {
516
  'ecommerce': {
517
  'checkout': {
518
  'actionField': {
519
- 'step': 3 + window.gtm4wp_checkout_step_offset
520
  },
521
  'products': window.gtm4wp_checkout_products
522
  }
@@ -542,7 +543,7 @@ jQuery(function() {
542
  'ecommerce': {
543
  'checkout': {
544
  'actionField': {
545
- 'step': 4 + window.gtm4wp_checkout_step_offset
546
  },
547
  'products': window.gtm4wp_checkout_products
548
  }
@@ -556,7 +557,13 @@ jQuery(function() {
556
  if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
557
  // shipping methods are not visible if only one is available
558
  // and if the user has already a pre-selected method, no click event will fire to report the checkout step
559
- jQuery( 'input[name^=shipping_method]:checked' ).trigger( 'change' );
 
 
 
 
 
 
560
  }
561
 
562
  if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) == -1 ) {
@@ -564,14 +571,17 @@ jQuery(function() {
564
  jQuery( 'input[name=payment_method]:checked' ).trigger( 'change' );
565
  }
566
 
567
- var _shipping_el = jQuery( '#shipping_method input:checked' );
 
 
 
568
  if ( _shipping_el.length > 0 ) {
569
  window[ gtm4wp_datalayer_name ].push({
570
  'event': 'gtm4wp.checkoutOptionEEC',
571
  'ecommerce': {
572
  'checkout_option': {
573
  'actionField': {
574
- 'step': 3 + window.gtm4wp_checkout_step_offset,
575
  'option': 'Shipping: ' + _shipping_el.val()
576
  }
577
  }
@@ -586,7 +596,7 @@ jQuery(function() {
586
  'ecommerce': {
587
  'checkout_option': {
588
  'actionField': {
589
- 'step': 4 + window.gtm4wp_checkout_step_offset,
590
  'option': 'Payment: ' + _payment_el.val()
591
  }
592
  }
472
  if ( is_checkout ) {
473
  window.gtm4wp_checkout_step_offset = window.gtm4wp_checkout_step_offset || 0;
474
  window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || [];
475
+ var gtm4wp_shipping_payment_method_step_offset = window.gtm4wp_needs_shipping_address ? 0 : -1;
476
  var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
477
 
478
  jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name^=shipping_method])', function() {
517
  'ecommerce': {
518
  'checkout': {
519
  'actionField': {
520
+ 'step': 3 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset
521
  },
522
  'products': window.gtm4wp_checkout_products
523
  }
543
  'ecommerce': {
544
  'checkout': {
545
  'actionField': {
546
+ 'step': 4 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset
547
  },
548
  'products': window.gtm4wp_checkout_products
549
  }
557
  if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
558
  // shipping methods are not visible if only one is available
559
  // and if the user has already a pre-selected method, no click event will fire to report the checkout step
560
+ var selected_shipping_method = jQuery( 'input[name^=shipping_method]:checked' );
561
+ if ( selected_shipping_method.length == 0 ) {
562
+ selected_shipping_method = jQuery( 'input[name^=shipping_method]:first' );
563
+ }
564
+ if ( selected_shipping_method.length > 0 ) {
565
+ selected_shipping_method.trigger( 'change' );
566
+ }
567
  }
568
 
569
  if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) == -1 ) {
571
  jQuery( 'input[name=payment_method]:checked' ).trigger( 'change' );
572
  }
573
 
574
+ var _shipping_el = jQuery( 'input[name^=shipping_method]:checked' );
575
+ if ( _shipping_el.length == 0 ) {
576
+ _shipping_el = jQuery( 'input[name^=shipping_method]:first' );
577
+ }
578
  if ( _shipping_el.length > 0 ) {
579
  window[ gtm4wp_datalayer_name ].push({
580
  'event': 'gtm4wp.checkoutOptionEEC',
581
  'ecommerce': {
582
  'checkout_option': {
583
  'actionField': {
584
+ 'step': 3 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset,
585
  'option': 'Shipping: ' + _shipping_el.val()
586
  }
587
  }
596
  'ecommerce': {
597
  'checkout_option': {
598
  'actionField': {
599
+ 'step': 4 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset,
600
  'option': 'Payment: ' + _payment_el.val()
601
  }
602
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, goo
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
  Tested up to: 5.4
8
- Stable tag: 1.11.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
@@ -258,6 +258,12 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
258
 
259
  == Changelog ==
260
 
 
 
 
 
 
 
261
  = 1.11.3 =
262
 
263
  * Fixed: use var_export instead of var_dump in some debug code,
@@ -660,6 +666,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
660
 
661
  == Upgrade Notice ==
662
 
 
 
 
 
663
  = 1.11.3 =
664
 
665
  Some bugfixes and adding support for the latest WordPress and WooCommerce version
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
  Tested up to: 5.4
8
+ Stable tag: 1.11.4
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
258
 
259
  == Changelog ==
260
 
261
+ = 1.11.4 =
262
+
263
+ * Fixed: fire gtm4wp.checkoutStepEEC and gtm4wp.checkoutOptionEEC events if there is only one shipping method available and it is hidden from the user
264
+ * Fixed: decrease checkout step numbers 3 and 4 if shipping destination is set to 'Force shipping to the customer billing address' in WooCommerce. This way there will be no gap in Checkout behaviour report in Google Analytics.
265
+ * Updated: tested version number for WooCommerce
266
+
267
  = 1.11.3 =
268
 
269
  * Fixed: use var_export instead of var_dump in some debug code,
666
 
667
  == Upgrade Notice ==
668
 
669
+ = 1.11.4 =
670
+
671
+ Bugfix and updated tested version number for WooCommerce
672
+
673
  = 1.11.3 =
674
 
675
  Some bugfixes and adding support for the latest WordPress and WooCommerce version