DuracellTomi's Google Tag Manager for WordPress - Version 1.11.5

Version Description

  • Fixed: new Google Optimize container ID format accepted now
Download this release

Release Info

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

Code changes from version 1.11.4 to 1.11.5

admin/admin.php CHANGED
@@ -567,13 +567,12 @@ $GLOBALS['gtm4wp_integratefieldtexts'] = array(
567
  'description' => sprintf(
568
  __(
569
  'Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />' .
570
- 'This plugin will add the <a href="%s">page-hiding snippet</a> to your pages.<br /><br />' .
571
- 'The Google Optimize container will be only loaded if you provide your Google Analytics property ID bellow as well.',
572
  'duracelltomi-google-tag-manager'
573
  ),
574
  'https://developers.google.com/optimize/#the_page-hiding_snippet_code'
575
  ) .
576
- '<br /><span class="goid_validation_error">' . __( 'This does not seems to be a valid Google Optimize ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
577
  'phase' => GTM4WP_PHASE_EXPERIMENTAL,
578
  ),
579
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
@@ -581,13 +580,6 @@ $GLOBALS['gtm4wp_integratefieldtexts'] = array(
581
  'description' => __( 'Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.', 'duracelltomi-google-tag-manager' ),
582
  'phase' => GTM4WP_PHASE_EXPERIMENTAL,
583
  ),
584
- GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID => array(
585
- 'label' => __( 'Google Optimize - Google Analytics property ID', 'duracelltomi-google-tag-manager' ),
586
- 'description' => __( 'If you enter your Google Analytics property ID here as well (UA-NNNNNN-N), this plugin will also load your Google Optimize container itself. Leave this blank to only load the page hiding snippet.', 'duracelltomi-google-tag-manager' ) .
587
- '<br /><span class="goid_ga_validation_error">' . __( 'This does not seems to be a valid Google Analytics property ID! Valid format: UA-NNNNNN-N where N can be numbers. Enter a single property ID here.', 'duracelltomi-google-tag-manager' ) . '</span>',
588
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
589
- ),
590
-
591
  GTM4WP_OPTION_INTEGRATE_AMPID => array(
592
  'label' => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
593
  'description' => sprintf( __( 'Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href="%s">AMP GTM snippet</a> to your AMP pages.', 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
@@ -913,32 +905,15 @@ function gtm4wp_sanitize_options( $options ) {
913
  $_goid_haserror = false;
914
 
915
  foreach ( $_goid_list as $one_go_id ) {
916
- $_goid_haserror = $_goid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_go_id );
917
  }
918
 
919
  if ( $_goid_haserror && ( count( $_goid_list ) > 0 ) ) {
920
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Optimize ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
921
  } else {
922
  $output[ $optionname ] = $newoptionvalue;
923
  }
924
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ) {
925
- $_gaid_val = trim( $newoptionvalue );
926
- if ( '' == $_gaid_val ) {
927
- $_gaid_list = array();
928
- } else {
929
- $_gaid_list = explode( ',', $_gaid_val );
930
- }
931
- $_gaid_haserror = false;
932
 
933
- foreach ( $_gaid_list as $one_ga_id ) {
934
- $_gaid_haserror = $_gaid_haserror || ! preg_match( '/^UA-[0-9]+-[0-9]+$/', $one_ga_id );
935
- }
936
-
937
- if ( $_gaid_haserror && ( count( $_gaid_list ) > 0 ) ) {
938
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Analytics property ID. Valid ID format: UA-NNNNNN-N.', 'duracelltomi-google-tag-manager' ) );
939
- } else {
940
- $output[ $optionname ] = $newoptionvalue;
941
- }
942
  } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
943
  $output[ $optionname ] = (int) $newoptionvalue;
944
 
@@ -1364,7 +1339,7 @@ function gtm4wp_admin_head() {
1364
 
1365
  jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-idlist\\\\]" )
1366
  .bind( "blur", function() {
1367
- var goid_regex = /^GTM-[A-Z0-9]+$/;
1368
  var goid_val = jQuery( this ).val().trim();
1369
  if ( "" == goid_val ) {
1370
  goid_list = [];
567
  'description' => sprintf(
568
  __(
569
  'Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />' .
570
+ 'This plugin will add the <a href="%s">page-hiding snippet</a> to your pages.<br /><br />',
 
571
  'duracelltomi-google-tag-manager'
572
  ),
573
  'https://developers.google.com/optimize/#the_page-hiding_snippet_code'
574
  ) .
575
+ '<br /><span class="goid_validation_error">' . __( 'This does not seems to be a valid Google Optimize ID! Valid format: GTM-XXXXXX or OPT-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
576
  'phase' => GTM4WP_PHASE_EXPERIMENTAL,
577
  ),
578
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
580
  'description' => __( 'Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.', 'duracelltomi-google-tag-manager' ),
581
  'phase' => GTM4WP_PHASE_EXPERIMENTAL,
582
  ),
 
 
 
 
 
 
 
583
  GTM4WP_OPTION_INTEGRATE_AMPID => array(
584
  'label' => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
585
  'description' => sprintf( __( 'Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href="%s">AMP GTM snippet</a> to your AMP pages.', 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
905
  $_goid_haserror = false;
906
 
907
  foreach ( $_goid_list as $one_go_id ) {
908
+ $_goid_haserror = $_goid_haserror || ! preg_match( '/^(GTM|OPT)-[A-Z0-9]+$/', $one_go_id );
909
  }
910
 
911
  if ( $_goid_haserror && ( count( $_goid_list ) > 0 ) ) {
912
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Optimize ID. Valid ID format: GTM-XXXXX or OPT-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
913
  } else {
914
  $output[ $optionname ] = $newoptionvalue;
915
  }
 
 
 
 
 
 
 
 
916
 
 
 
 
 
 
 
 
 
 
917
  } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
918
  $output[ $optionname ] = (int) $newoptionvalue;
919
 
1339
 
1340
  jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-idlist\\\\]" )
1341
  .bind( "blur", function() {
1342
+ var goid_regex = /^(GTM|OPT)-[A-Z0-9]+$/;
1343
  var goid_val = jQuery( this ).val().trim();
1344
  if ( "" == goid_val ) {
1345
  goid_list = [];
common/readoptions.php CHANGED
@@ -115,7 +115,6 @@ define( 'GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG', 'integrate-woocommerce-d
115
 
116
  define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS', 'integrate-google-optimize-idlist' );
117
  define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT', 'integrate-google-optimize-timeout' );
118
- define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID', 'integrate-google-optimize-gaid' );
119
 
120
  define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
121
 
@@ -245,7 +244,6 @@ $gtm4wp_defaultoptions = array(
245
 
246
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => '',
247
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => 4000,
248
- GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID => '',
249
 
250
  GTM4WP_OPTION_INTEGRATE_WPECOMMERCE => false,
251
 
115
 
116
  define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS', 'integrate-google-optimize-idlist' );
117
  define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT', 'integrate-google-optimize-timeout' );
 
118
 
119
  define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
120
 
244
 
245
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => '',
246
  GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => 4000,
 
247
 
248
  GTM4WP_OPTION_INTEGRATE_WPECOMMERCE => false,
249
 
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.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,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.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;
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
  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;
integration/google-optimize.php CHANGED
@@ -15,47 +15,50 @@ function gtm4wp_go_pagehiding_snippet() {
15
  }
16
 
17
  echo "
18
- <!-- GTM4WP: Google Optimize Page Hiding snippet -->
19
- <style>.google-optimize-hide { opacity: 0 !important} </style>
20
- <script data-cfasync=\"false\">
21
- (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
22
- h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
23
- (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;})
24
- (window,document.documentElement,'google-optimize-hide','dataLayer'," . $gtm4wp_gotimeout . ',{' . implode( ', ', $gtm4wp_goid_pagehiding_list ) . '});
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  </script>
26
- <!-- GTM4WP: End of Google Optimize Page Hiding snippet -->';
27
  }
28
  }
29
 
30
  function gtm4wp_go_snippet( $content ) {
31
  global $gtm4wp_options;
32
 
33
- if ( '' == $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ] ) {
34
- return $content;
35
- }
36
-
37
  $gtm4wp_goids = explode( ',', $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] );
38
  $gtm4wp_goid_list = array();
39
  if ( count( $gtm4wp_goids ) > 0 ) {
40
  foreach ( $gtm4wp_goids as $gtm4wp_onegoid ) {
41
- $gtm4wp_goid_list[] = "ga('require', '" . $gtm4wp_onegoid . "');";
 
42
  }
43
 
44
  $content .= "
45
  <!-- GTM4WP: Load Google Optimize containers -->
46
- <script>
47
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
48
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
49
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
50
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
51
- ga('create', '" . $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ] . "', 'auto');
52
- " . implode( "\n", $gtm4wp_goid_list ) . '
53
- </script>
54
- <!-- GTM4WP: End of Load Google Optimize containers -->';
55
  }
56
 
57
  return $content;
58
  }
59
 
60
  add_action( 'wp_head', 'gtm4wp_go_pagehiding_snippet', 1 );
61
- add_filter( GTM4WP_WPFILTER_AFTER_DATALAYER, 'gtm4wp_go_snippet' );
15
  }
16
 
17
  echo "
18
+ <!-- GTM4WP: Google Optimize Anti-flicker snippet -->
19
+ <style>
20
+ .async-hide {
21
+ opacity: 0 !important
22
+ }
23
+ </style>
24
+ <script>
25
+ (function(a,s,y,n,c,h,i,d,e) {
26
+ s.className+=' '+y;
27
+ h.start=1*new Date;
28
+ h.end=i=function() {
29
+ s.className=s.className.replace(RegExp(' ?'+y),'')
30
+ };
31
+ (a[n]=a[n]||[]).hide=h;
32
+ setTimeout(function() {
33
+ i();
34
+ h.end=null
35
+ },c);
36
+ h.timeout=c;
37
+ })(window,document.documentElement,'async-hide','dataLayer'," . $gtm4wp_gotimeout . ",{" . implode( ", ", $gtm4wp_goid_pagehiding_list ) . "});
38
  </script>
39
+ <!-- GTM4WP: End of Google Optimize Page Hiding snippet -->";
40
  }
41
  }
42
 
43
  function gtm4wp_go_snippet( $content ) {
44
  global $gtm4wp_options;
45
 
 
 
 
 
46
  $gtm4wp_goids = explode( ',', $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] );
47
  $gtm4wp_goid_list = array();
48
  if ( count( $gtm4wp_goids ) > 0 ) {
49
  foreach ( $gtm4wp_goids as $gtm4wp_onegoid ) {
50
+ $gtm4wp_goid_list[] = '
51
+ <script src="https://www.googleoptimize.com/optimize.js?id=' . $gtm4wp_onegoid . '" onerror="dataLayer.hide.end && dataLayer.hide.end()"></script>';
52
  }
53
 
54
  $content .= "
55
  <!-- GTM4WP: Load Google Optimize containers -->
56
+ " . implode("", $gtm4wp_goid_list) . "
57
+ <!-- GTM4WP: End of Load Google Optimize containers -->";
 
 
 
 
 
 
 
58
  }
59
 
60
  return $content;
61
  }
62
 
63
  add_action( 'wp_head', 'gtm4wp_go_pagehiding_snippet', 1 );
64
+ add_filter( GTM4WP_WPFILTER_AFTER_DATALAYER, 'gtm4wp_go_snippet' );
js/admin-subtabs.js CHANGED
@@ -71,7 +71,7 @@ var adminsubtabs = {
71
  },
72
  "int-google-optimize": {
73
  tabtext: gtm4wp.gotabtitle,
74
- numitems: 3
75
  },
76
  "int-amp": {
77
  tabtext: gtm4wp.amptabtitle,
71
  },
72
  "int-google-optimize": {
73
  tabtext: gtm4wp.gotabtitle,
74
+ numitems: 2
75
  },
76
  "int-amp": {
77
  tabtext: gtm4wp.amptabtitle,
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.4
8
- Stable tag: 1.11.4
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
@@ -258,6 +258,10 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
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
@@ -666,6 +670,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
666
 
667
  == Upgrade Notice ==
668
 
 
 
 
 
669
  = 1.11.4 =
670
 
671
  Bugfix and updated tested version number for WooCommerce
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
 
259
  == Changelog ==
260
 
261
+ = 1.11.5 =
262
+
263
+ * Fixed: new Google Optimize container ID format accepted now
264
+
265
  = 1.11.4 =
266
 
267
  * Fixed: fire gtm4wp.checkoutStepEEC and gtm4wp.checkoutOptionEEC events if there is only one shipping method available and it is hidden from the user
670
 
671
  == Upgrade Notice ==
672
 
673
+ = 1.11.5 =
674
+
675
+ Fixed: new Google Optimize container ID format accepted now
676
+
677
  = 1.11.4 =
678
 
679
  Bugfix and updated tested version number for WooCommerce