Google Analytics Dashboard for WP (GADWP) - Version 5.3

Version Description

  • release notes
  • Enhancements:
    • adds full support for Global Site Tag (gtag.js)
    • remove Scroll Depth functionality, since this is now available as a trigger on Google Tag Manager
    • adds custom dimensions support for AMP pages with Google Tag Manager tracking
    • adds support for button submits
  • Bug Fixes:
    • form submit events were not following the non-interaction settings
Download this release

Release Info

Developer deconf
Plugin Icon 128x128 Google Analytics Dashboard for WP (GADWP)
Version 5.3
Comparing to
See all releases

Code changes from version 5.2.3.1 to 5.3

admin/settings.php CHANGED
@@ -43,6 +43,7 @@ final class GADWP_Settings {
43
  $options['optimize_tracking'] = 0;
44
  $options['trackingcode_infooter'] = 0;
45
  $options['trackingevents_infooter'] = 0;
 
46
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
47
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
48
  }
@@ -421,6 +422,18 @@ final class GADWP_Settings {
421
  <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
422
  </td>
423
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
424
  <?php elseif ( 'tagmanager' == $options['tracking_type'] ) : ?>
425
  <tr>
426
  <td class="gadwp-settings-title">
@@ -705,21 +718,6 @@ final class GADWP_Settings {
705
  </select>
706
  </td>
707
  </tr>
708
- <tr>
709
- <td colspan="2"><?php echo "<h2>" . __( "Page Scrolling Depth Variables", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
710
- </tr>
711
- <tr>
712
- <td colspan="2" class="gadwp-settings-title">
713
- <div class="button-primary gadwp-settings-switchoo">
714
- <input type="checkbox" name="options[tm_pagescrolldepth_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="tm_pagescrolldepth_tracking" <?php checked( $options['tm_pagescrolldepth_tracking'], 1 ); ?>>
715
- <label class="gadwp-settings-switchoo-label" for="tm_pagescrolldepth_tracking">
716
- <div class="gadwp-settings-switchoo-inner"></div>
717
- <div class="gadwp-settings-switchoo-switch"></div>
718
- </label>
719
- </div>
720
- <div class="switch-desc"><?php echo " ".__("enable page scrolling depth variables: ", 'google-analytics-dashboard-for-wp' ) . "<strong>{{event}} = ScrollDistance, {{eventCategory}}, {{eventAction}}, {{eventLabel}}, {{eventValue}}, {{eventNonInteraction}}</strong>"?></div>
721
- </td>
722
- </tr>
723
  </table>
724
  </div>
725
  <div id="gadwp-advanced">
@@ -834,7 +832,7 @@ final class GADWP_Settings {
834
  <tr>
835
  <td colspan="2" class="gadwp-settings-title">
836
  <div class="button-primary gadwp-settings-switchoo">
837
- <input type="checkbox" name="options[ga_force_ssl]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_force_ssl" <?php checked( $options['ga_force_ssl'], 1 ); ?>>
838
  <label class="gadwp-settings-switchoo-label" for="ga_force_ssl">
839
  <div class="gadwp-settings-switchoo-inner"></div>
840
  <div class="gadwp-settings-switchoo-switch"></div>
@@ -920,7 +918,7 @@ final class GADWP_Settings {
920
  <tr>
921
  <td colspan="2" class="gadwp-settings-title">
922
  <div class="button-primary gadwp-settings-switchoo">
923
- <input type="checkbox" name="options[amp_tracking_clientidapi]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_clientidapi" <?php checked( $options['amp_tracking_clientidapi'], 1 ); ?>>
924
  <label class="gadwp-settings-switchoo-label" for="amp_tracking_clientidapi">
925
  <div class="gadwp-settings-switchoo-inner"></div>
926
  <div class="gadwp-settings-switchoo-switch"></div>
@@ -938,10 +936,10 @@ final class GADWP_Settings {
938
  </label>
939
  </td>
940
  <td>
941
- <select id="ecommerce_mode" name="options[ecommerce_mode]">
942
  <option value="disabled" <?php selected( $options['ecommerce_mode'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
943
  <option value="standard" <?php selected( $options['ecommerce_mode'], 'standard' ); ?>><?php _e("Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
944
- <option value="enhanced" <?php selected( $options['ecommerce_mode'], 'enhanced' ); ?>><?php _e("Enhanced Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
945
  </select>
946
  </td>
947
  </tr>
43
  $options['optimize_tracking'] = 0;
44
  $options['trackingcode_infooter'] = 0;
45
  $options['trackingevents_infooter'] = 0;
46
+ $options['ga_with_gtag'] = 0;
47
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
48
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
49
  }
422
  <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
423
  </td>
424
  </tr>
425
+ <tr>
426
+ <td colspan="2" class="gadwp-settings-title">
427
+ <div class="button-primary gadwp-settings-switchoo">
428
+ <input type="checkbox" name="options[ga_with_gtag]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_with_gtag" <?php checked( $options['ga_with_gtag'], 1 ); ?>>
429
+ <label class="gadwp-settings-switchoo-label" for="ga_with_gtag">
430
+ <div class="gadwp-settings-switchoo-inner"></div>
431
+ <div class="gadwp-settings-switchoo-switch"></div>
432
+ </label>
433
+ </div>
434
+ <div class="switch-desc"><?php echo " ".__("use global site tag gtag.js (not recommended)", 'google-analytics-dashboard-for-wp' );?></div>
435
+ </td>
436
+ </tr>
437
  <?php elseif ( 'tagmanager' == $options['tracking_type'] ) : ?>
438
  <tr>
439
  <td class="gadwp-settings-title">
718
  </select>
719
  </td>
720
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
  </table>
722
  </div>
723
  <div id="gadwp-advanced">
832
  <tr>
833
  <td colspan="2" class="gadwp-settings-title">
834
  <div class="button-primary gadwp-settings-switchoo">
835
+ <input type="checkbox" name="options[ga_force_ssl]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_force_ssl" <?php checked( $options['ga_force_ssl'] || $options['ga_with_gtag'], 1 ); ?> <?php disabled( $options['ga_with_gtag'], true );?>>
836
  <label class="gadwp-settings-switchoo-label" for="ga_force_ssl">
837
  <div class="gadwp-settings-switchoo-inner"></div>
838
  <div class="gadwp-settings-switchoo-switch"></div>
918
  <tr>
919
  <td colspan="2" class="gadwp-settings-title">
920
  <div class="button-primary gadwp-settings-switchoo">
921
+ <input type="checkbox" name="options[amp_tracking_clientidapi]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_clientidapi" <?php checked( $options['amp_tracking_clientidapi'] && !$options['ga_with_gtag'], 1 ); ?> <?php disabled( $options['ga_with_gtag'], true );?>>
922
  <label class="gadwp-settings-switchoo-label" for="amp_tracking_clientidapi">
923
  <div class="gadwp-settings-switchoo-inner"></div>
924
  <div class="gadwp-settings-switchoo-switch"></div>
936
  </label>
937
  </td>
938
  <td>
939
+ <select id="ecommerce_mode" name="options[ecommerce_mode]" <?php disabled( $options['ga_with_gtag'], true );?>>
940
  <option value="disabled" <?php selected( $options['ecommerce_mode'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
941
  <option value="standard" <?php selected( $options['ecommerce_mode'], 'standard' ); ?>><?php _e("Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
942
+ <option value="enhanced" <?php selected( $options['ecommerce_mode'], 'enhanced' ); selected( $options['ga_with_gtag'], true );?>><?php _e("Enhanced Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
943
  </select>
944
  </td>
945
  </tr>
config.php CHANGED
@@ -98,6 +98,7 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
98
  'backend_realtime_report',
99
  'ga_optout',
100
  'ga_dnt_optout',
 
101
  );
102
  foreach ( $numerics as $key ) {
103
  if ( isset( $options[$key] ) ) {
@@ -238,6 +239,11 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
238
  } else {
239
  GADWP_Tools::delete_cache( 'gapi_errors' );
240
  }
 
 
 
 
 
241
  }
242
 
243
  /* @formatter:off */
@@ -280,6 +286,7 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
280
  'backend_realtime_report', //v5.2
281
  'ga_optout', //v5.2.3
282
  'ga_dnt_optout', //v5.2.3
 
283
  );
284
  foreach ( $zeros as $key ) {
285
  if ( ! isset( $this->options[$key] ) ) {
98
  'backend_realtime_report',
99
  'ga_optout',
100
  'ga_dnt_optout',
101
+ 'ga_with_gtag',
102
  );
103
  foreach ( $numerics as $key ) {
104
  if ( isset( $options[$key] ) ) {
239
  } else {
240
  GADWP_Tools::delete_cache( 'gapi_errors' );
241
  }
242
+
243
+ // Enable GADWP EndPoint for those updating from a version lower than 5.2, introduced in GADWP v5.3
244
+ if (version_compare( $prevver, '5.2', '<' ) ) {
245
+ $this->options['with_endpoint'] = 2;
246
+ }
247
  }
248
 
249
  /* @formatter:off */
286
  'backend_realtime_report', //v5.2
287
  'ga_optout', //v5.2.3
288
  'ga_dnt_optout', //v5.2.3
289
+ 'ga_with_gtag', //v5.3
290
  );
291
  foreach ( $zeros as $key ) {
292
  if ( ! isset( $this->options[$key] ) ) {
front/js/tracking-analytics-events.js CHANGED
@@ -1 +1 @@
1
- "use strict";var gadwpRedirectLink;var gadwpRedirectCalled=false;var gadwpDefaultPrevented=false;function gadwpRedirect(){if(gadwpRedirectCalled){return}gadwpRedirectCalled=true;if(gadwpDefaultPrevented==false){document.location.href=gadwpRedirectLink}else{gadwpDefaultPrevented=false}}jQuery(window).on("load",function(){if(gadwpUAEventsData.options.event_tracking){jQuery("a").filter(function(){if(typeof this.href==="string"){var a=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$");return this.href.match(a)}}).click(function(d){var b=this.getAttribute("data-vars-ga-category")||"download";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}});jQuery('a[href^="mailto"]').click(function(d){var b=this.getAttribute("data-vars-ga-category")||"email";var c=this.getAttribute("data-vars-ga-action")||"send";var a=this.getAttribute("data-vars-ga-label")||this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}});jQuery('a[href^="tel"]').click(function(d){var b=this.getAttribute("data-vars-ga-category")||"telephone";var c=this.getAttribute("data-vars-ga-action")||"call";var a=this.getAttribute("data-vars-ga-label")||this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}});if(gadwpUAEventsData.options.root_domain){jQuery('a[href^="http"]').filter(function(){if(typeof this.href==="string"){var a=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$")}if(a&&!this.href.match(a)){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)==-1&&this.href.indexOf("://")>-1){return this.href}}}).click(function(d){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;var b=this.getAttribute("data-vars-ga-category")||"outbound";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(d.isDefaultPrevented()){gadwpDefaultPrevented=true;gadwpRedirectCalled=false}}else{gadwpRedirectCalled=true;gadwpDefaultPrevented=false}if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1,hitCallback:gadwpRedirect})}else{ga("send","event",b,c,a,{hitCallback:gadwpRedirect})}setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}}})}}if(gadwpUAEventsData.options.event_affiliates&&gadwpUAEventsData.options.aff_tracking){jQuery("a").filter(function(){if(gadwpUAEventsData.options.event_affiliates!=""){if(typeof this.href==="string"){var a=new RegExp("("+gadwpUAEventsData.options.event_affiliates.replace(/\//g,"/")+")");return this.href.match(a)}}}).click(function(d){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;var b=this.getAttribute("data-vars-ga-category")||"affiliates";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(d.isDefaultPrevented()){gadwpDefaultPrevented=true;gadwpRedirectCalled=false}}else{gadwpRedirectCalled=true;gadwpDefaultPrevented=false}if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1,hitCallback:gadwpRedirect})}else{ga("send","event",b,c,a,{hitCallback:gadwpRedirect})}setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}}})}if(gadwpUAEventsData.options.root_domain&&gadwpUAEventsData.options.hash_tracking){jQuery("a").filter(function(){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)!=-1||this.href.indexOf("://")==-1){return this.hash}}).click(function(d){var b=this.getAttribute("data-vars-ga-category")||"hashmark";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}})}if(gadwpUAEventsData.options.event_formsubmit){jQuery('input[type="submit"]').click(function(f){var d=this;var b=d.getAttribute("data-vars-ga-category")||"form";var c=d.getAttribute("data-vars-ga-action")||"submit";var a=d.getAttribute("data-vars-ga-label")||d.name||d.value;if(gadwpUAEventsData.options.event_formsubmit){ga("send","event",b,c,a,{nonInteraction:1})}else{ga("send","event",b,c,a)}})}if(gadwpUAEventsData.options.ga_pagescrolldepth_tracking){jQuery.scrollDepth({percentage:true,userTiming:false,pixelDepth:false,gtmOverride:true,nonInteraction:true})}});
1
+ "use strict";var gadwpRedirectLink;var gadwpRedirectCalled=false;var gadwpDefaultPrevented=false;function gadwpRedirect(){if(gadwpRedirectCalled){return}gadwpRedirectCalled=true;if(gadwpDefaultPrevented==false){document.location.href=gadwpRedirectLink}else{gadwpDefaultPrevented=false}}function gadwp_send_event(c,d,a,b){if(gadwpUAEventsData.options.ga_with_gtag){if(b){if(gadwpUAEventsData.options.event_bouncerate){gtag("event",d,{event_category:c,event_label:a,non_interaction:1,event_callback:gadwpRedirect})}else{gtag("event",d,{event_category:c,event_label:a,event_callback:gadwpRedirect})}}else{if(gadwpUAEventsData.options.event_bouncerate){gtag("event",d,{event_category:c,event_label:a,non_interaction:1})}else{gtag("event",d,{event_category:c,event_label:a})}}}else{if(b){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",c,d,a,{nonInteraction:1,hitCallback:gadwpRedirect})}else{ga("send","event",c,d,a,{hitCallback:gadwpRedirect})}}else{if(gadwpUAEventsData.options.event_bouncerate){ga("send","event",c,d,a,{nonInteraction:1})}else{ga("send","event",c,d,a)}}}}jQuery(window).on("load",function(){if(gadwpUAEventsData.options.event_tracking){jQuery("a").filter(function(){if(typeof this.href==="string"){var a=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$");return this.href.match(a)}}).click(function(d){var b=this.getAttribute("data-vars-ga-category")||"download";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;gadwp_send_event(b,c,a,false)});jQuery('a[href^="mailto"]').click(function(d){var b=this.getAttribute("data-vars-ga-category")||"email";var c=this.getAttribute("data-vars-ga-action")||"send";var a=this.getAttribute("data-vars-ga-label")||this.href;gadwp_send_event(b,c,a,false)});jQuery('a[href^="tel"]').click(function(d){var b=this.getAttribute("data-vars-ga-category")||"telephone";var c=this.getAttribute("data-vars-ga-action")||"call";var a=this.getAttribute("data-vars-ga-label")||this.href;gadwp_send_event(b,c,a,false)});if(gadwpUAEventsData.options.root_domain){jQuery('a[href^="http"]').filter(function(){if(typeof this.href==="string"){var a=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$")}if(a&&!this.href.match(a)){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)==-1&&this.href.indexOf("://")>-1){return this.href}}}).click(function(d){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;var b=this.getAttribute("data-vars-ga-category")||"outbound";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(d.isDefaultPrevented()){gadwpDefaultPrevented=true;gadwpRedirectCalled=false}}else{gadwpRedirectCalled=true;gadwpDefaultPrevented=false}if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){gadwp_send_event(b,c,a,true);setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{gadwp_send_event(b,c,a,false)}})}}if(gadwpUAEventsData.options.event_affiliates&&gadwpUAEventsData.options.aff_tracking){jQuery("a").filter(function(){if(gadwpUAEventsData.options.event_affiliates!=""){if(typeof this.href==="string"){var a=new RegExp("("+gadwpUAEventsData.options.event_affiliates.replace(/\//g,"/")+")");return this.href.match(a)}}}).click(function(d){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;var b=this.getAttribute("data-vars-ga-category")||"affiliates";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){if(d.isDefaultPrevented()){gadwpDefaultPrevented=true;gadwpRedirectCalled=false}}else{gadwpRedirectCalled=true;gadwpDefaultPrevented=false}if(this.target!="_blank"&&gadwpUAEventsData.options.event_precision){gadwp_send_event(b,c,a,true);setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{gadwp_send_event(b,c,a,false)}})}if(gadwpUAEventsData.options.root_domain&&gadwpUAEventsData.options.hash_tracking){jQuery("a").filter(function(){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)!=-1||this.href.indexOf("://")==-1){return this.hash}}).click(function(d){var b=this.getAttribute("data-vars-ga-category")||"hashmark";var c=this.getAttribute("data-vars-ga-action")||"click";var a=this.getAttribute("data-vars-ga-label")||this.href;gadwp_send_event(b,c,a,false)})}if(gadwpUAEventsData.options.event_formsubmit){jQuery('input[type="submit"], button[type="submit"]').click(function(f){var d=this;var b=d.getAttribute("data-vars-ga-category")||"form";var c=d.getAttribute("data-vars-ga-action")||"submit";var a=d.getAttribute("data-vars-ga-label")||d.name||d.value;gadwp_send_event(b,c,a,false)})}if(gadwpUAEventsData.options.ga_pagescrolldepth_tracking){jQuery.scrollDepth({percentage:true,userTiming:false,pixelDepth:false,gtmOverride:true,nonInteraction:true})}});
front/js/tracking-scrolldepth.js CHANGED
@@ -1,7 +1 @@
1
- /*!
2
- * @preserve
3
- * jquery.scrolldepth.js | v1.0
4
- * Copyright (c) 2016 Rob Flaherty (@robflaherty)
5
- * Licensed under the MIT and GPL licenses.
6
- */
7
- (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module==="object"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(g){var f={minHeight:0,elements:[],percentage:true,userTiming:true,pixelDepth:true,nonInteraction:true,gaGlobal:false,gtmOverride:false,trackerName:false,dataLayer:"dataLayer"};var b=g(window),a=[],h=false,d=0,c,j,e,i;g.scrollDepth=function(t){var l=+new Date;t=g.extend({},f,t);if(g(document).height()<t.minHeight){return}if(t.gaGlobal){c=true;e=t.gaGlobal}else{if(typeof ga==="function"){c=true;e="ga"}else{if(typeof __gaTracker==="function"){c=true;e="__gaTracker"}}}if(typeof _gaq!=="undefined"&&typeof _gaq.push==="function"){j=true}if(typeof t.eventHandler==="function"){i=t.eventHandler}else{if(typeof window[t.dataLayer]!=="undefined"&&typeof window[t.dataLayer].push==="function"&&!t.gtmOverride){i=function(u){window[t.dataLayer].push(u)}}}function r(x,v,u,w){var y=t.trackerName?(t.trackerName+".send"):"send";if(i){i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:x,eventLabel:v,eventValue:1,eventNonInteraction:t.nonInteraction});if(t.pixelDepth&&arguments.length>2&&u>d){d=u;i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:m(u),eventValue:1,eventNonInteraction:t.nonInteraction})}if(t.userTiming&&arguments.length>3){i({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:x,eventLabel:v,eventTiming:w})}}else{if(c){window[e](y,"event","Scroll Depth",x,v,1,{nonInteraction:t.nonInteraction});if(t.pixelDepth&&arguments.length>2&&u>d){d=u;window[e](y,"event","Scroll Depth","Pixel Depth",m(u),1,{nonInteraction:t.nonInteraction})}if(t.userTiming&&arguments.length>3){window[e](y,"timing","Scroll Depth",x,w,v)}}if(j){_gaq.push(["_trackEvent","Scroll Depth",x,v,1,t.nonInteraction]);if(t.pixelDepth&&arguments.length>2&&u>d){d=u;_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",m(u),1,t.nonInteraction])}if(t.userTiming&&arguments.length>3){_gaq.push(["_trackTiming","Scroll Depth",x,w,v,100])}}}}function q(u){return{"25%":parseInt(u*0.25,10),"50%":parseInt(u*0.5,10),"75%":parseInt(u*0.75,10),"100%":u-5}}function o(v,u,w){g.each(v,function(x,y){if(g.inArray(x,a)===-1&&u>=y){r("Percentage",x,u,w);a.push(x)}})}function n(w,u,v){g.each(w,function(x,y){if(g.inArray(y,a)===-1&&g(y).length){if(u>=g(y).offset().top){r("Elements",y,u,v);a.push(y)}}})}function m(u){return(Math.floor(u/250)*250).toString()}function s(){k()}g.scrollDepth.reset=function(){a=[];d=0;b.off("scroll.scrollDepth");k()};g.scrollDepth.addElements=function(u){if(typeof u=="undefined"||!g.isArray(u)){return}g.merge(t.elements,u);if(!h){k()}};g.scrollDepth.removeElements=function(u){if(typeof u=="undefined"||!g.isArray(u)){return}g.each(u,function(w,y){var v=g.inArray(y,t.elements);var x=g.inArray(y,a);if(v!=-1){t.elements.splice(v,1)}if(x!=-1){a.splice(x,1)}})};function p(z,B){var x,w,u;var A=null;var y=0;var v=function(){y=new Date;A=null;u=z.apply(x,w)};return function(){var C=new Date;if(!y){y=C}var D=B-(C-y);x=this;w=arguments;if(D<=0){clearTimeout(A);A=null;y=C;u=z.apply(x,w)}else{if(!A){A=setTimeout(v,D)}}return u}}function k(){h=true;b.on("scroll.scrollDepth",p(function(){var w=g(document).height(),v=window.innerHeight?window.innerHeight:b.height(),u=b.scrollTop()+v,x=q(w),y=+new Date-l;if(a.length>=t.elements.length+(t.percentage?4:0)){b.off("scroll.scrollDepth");h=false;return}if(t.elements){n(t.elements,u,y)}if(t.percentage){o(x,u,y)}},500))}s()};return g.scrollDepth}));
1
+ (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module==="object"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(g){var f={minHeight:0,elements:[],percentage:true,userTiming:true,pixelDepth:true,nonInteraction:true,gaGlobal:false,gtmOverride:false,trackerName:false,dataLayer:"dataLayer"};var b=g(window),a=[],h=false,d=0,c,j,e,k,i;g.scrollDepth=function(u){var m=+new Date;u=g.extend({},f,u);if(g(document).height()<u.minHeight){return}if(u.gaGlobal){c=true;e=u.gaGlobal}else{if(typeof gtag==="function"){k=true;e="gtag"}else{if(typeof ga==="function"){c=true;e="ga"}else{if(typeof __gaTracker==="function"){c=true;e="__gaTracker"}}}}if(typeof _gaq!=="undefined"&&typeof _gaq.push==="function"){j=true}if(typeof u.eventHandler==="function"){i=u.eventHandler}else{if(typeof window[u.dataLayer]!=="undefined"&&typeof window[u.dataLayer].push==="function"&&!u.gtmOverride){i=function(v){window[u.dataLayer].push(v)}}}function s(y,w,v,x){var z=u.trackerName?(u.trackerName+".send"):"send";if(i){i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:y,eventLabel:w,eventValue:1,eventNonInteraction:u.nonInteraction});if(u.pixelDepth&&arguments.length>2&&v>d){d=v;i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:n(v),eventValue:1,eventNonInteraction:u.nonInteraction})}if(u.userTiming&&arguments.length>3){i({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:y,eventLabel:w,eventTiming:x})}}else{if(k){window[e]("event",y,{event_category:"Scroll Depth",event_label:w,non_interaction:u.nonInteraction})}if(c){window[e](z,"event","Scroll Depth",y,w,1,{nonInteraction:u.nonInteraction});if(u.pixelDepth&&arguments.length>2&&v>d){d=v;window[e](z,"event","Scroll Depth","Pixel Depth",n(v),1,{nonInteraction:u.nonInteraction})}if(u.userTiming&&arguments.length>3){window[e](z,"timing","Scroll Depth",y,x,w)}}if(j){_gaq.push(["_trackEvent","Scroll Depth",y,w,1,u.nonInteraction]);if(u.pixelDepth&&arguments.length>2&&v>d){d=v;_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",n(v),1,u.nonInteraction])}if(u.userTiming&&arguments.length>3){_gaq.push(["_trackTiming","Scroll Depth",y,x,w,100])}}}}function r(v){return{"25%":parseInt(v*0.25,10),"50%":parseInt(v*0.5,10),"75%":parseInt(v*0.75,10),"100%":v-5}}function p(w,v,x){g.each(w,function(y,z){if(g.inArray(y,a)===-1&&v>=z){s("Percentage",y,v,x);a.push(y)}})}function o(x,v,w){g.each(x,function(y,z){if(g.inArray(z,a)===-1&&g(z).length){if(v>=g(z).offset().top){s("Elements",z,v,w);a.push(z)}}})}function n(v){return(Math.floor(v/250)*250).toString()}function t(){l()}g.scrollDepth.reset=function(){a=[];d=0;b.off("scroll.scrollDepth");l()};g.scrollDepth.addElements=function(v){if(typeof v=="undefined"||!g.isArray(v)){return}g.merge(u.elements,v);if(!h){l()}};g.scrollDepth.removeElements=function(v){if(typeof v=="undefined"||!g.isArray(v)){return}g.each(v,function(x,z){var w=g.inArray(z,u.elements);var y=g.inArray(z,a);if(w!=-1){u.elements.splice(w,1)}if(y!=-1){a.splice(y,1)}})};function q(A,C){var y,x,v;var B=null;var z=0;var w=function(){z=new Date;B=null;v=A.apply(y,x)};return function(){var D=new Date;if(!z){z=D}var E=C-(D-z);y=this;x=arguments;if(E<=0){clearTimeout(B);B=null;z=D;v=A.apply(y,x)}else{if(!B){B=setTimeout(w,E)}}return v}}function l(){h=true;b.on("scroll.scrollDepth",q(function(){var x=g(document).height(),w=window.innerHeight?window.innerHeight:b.height(),v=b.scrollTop()+w,y=r(x),z=+new Date-m;if(a.length>=u.elements.length+(u.percentage?4:0)){b.off("scroll.scrollDepth");h=false;return}if(u.elements){o(u.elements,v,z)}if(u.percentage){p(y,v,z)}},500))}t()};return g.scrollDepth}));
 
 
 
 
 
 
front/js/tracking-tagmanager-events.js DELETED
@@ -1 +0,0 @@
1
- jQuery(window).on("load",function(){jQuery.scrollDepth({percentage:true,userTiming:false,pixelDepth:false,gtmOverride:false})});
 
front/tracking-analytics.php CHANGED
@@ -27,7 +27,7 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics_Base' ) ) {
27
  $this->uaid = esc_html( $profile[2] );
28
  }
29
 
30
- protected function bulid_custom_dimensions() {
31
  $custom_dimensions = array();
32
 
33
  if ( $this->gadwp->config->options['ga_author_dimindex'] && ( is_single() || is_page() ) ) {
@@ -107,11 +107,11 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics_Base' ) ) {
107
  }
108
  }
109
 
110
- if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
111
 
112
- class GADWP_Tracking_Analytics extends GADWP_Tracking_Analytics_Base {
113
 
114
- private $commands;
115
 
116
  public function __construct() {
117
  parent::__construct();
@@ -121,38 +121,6 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
121
  if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_pagehiding'] && $this->gadwp->config->options['optimize_containerid'] ) {
122
  add_action( 'wp_head', array( $this, 'optimize_output' ), 99 );
123
  }
124
-
125
- if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
126
- add_action( 'wp_footer', array( $this, 'output' ), 99 );
127
- } else {
128
- add_action( 'wp_head', array( $this, 'output' ), 99 );
129
- }
130
- }
131
-
132
- /**
133
- * Retrieves the commands
134
- */
135
- public function get() {
136
- return $this->commands;
137
- }
138
-
139
- /**
140
- * Stores the commands
141
- * @param array $commands
142
- */
143
- public function set( $commands ) {
144
- $this->commands = $commands;
145
- }
146
-
147
- /**
148
- * Formats the command before being added to the commands
149
- * @param string $command
150
- * @param array $fields
151
- * @param string $fieldsobject
152
- * @return array
153
- */
154
- public function prepare( $command, $fields, $fieldsobject = null ) {
155
- return array( 'command' => $command, 'fields' => $fields, 'fieldsobject' => $fieldsobject );
156
  }
157
 
158
  /**
@@ -183,6 +151,7 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
183
  'event_precision' => $this->gadwp->config->options['ga_event_precision'],
184
  'event_formsubmit' => $this->gadwp->config->options ['ga_formsubmit_tracking'],
185
  'ga_pagescrolldepth_tracking' => $this->gadwp->config->options['ga_pagescrolldepth_tracking'],
 
186
  ),
187
  )
188
  );
@@ -191,13 +160,10 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
191
  }
192
 
193
  /**
194
- * Adds a formatted command to commands
195
- * @param string $command
196
- * @param array $fields
197
- * @param string $fieldsobject
198
  */
199
- private function add( $command, $fields, $fieldsobject = null ) {
200
- $this->commands[] = $this->prepare( $command, $fields, $fieldsobject );
201
  }
202
 
203
  /**
@@ -205,18 +171,70 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
205
  * @param string $value
206
  * @return string
207
  */
208
- private function filter( $value ) {
209
- if ( 'true' == $value || 'false' == $value ) {
210
  return $value;
211
  }
212
 
213
- if ( substr( $value, 0, 1 ) == '[' && substr( $value, - 1 ) == ']' ) {
214
  return $value;
215
  }
216
 
217
  return "'" . $value . "'";
218
  }
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  /**
221
  * Builds the commands based on user's options
222
  */
@@ -283,12 +301,12 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
283
  $this->add( 'set', $fields );
284
  }
285
 
286
- $custom_dimensions = $this->bulid_custom_dimensions();
287
  if ( ! empty( $custom_dimensions ) ) {
288
  foreach ( $custom_dimensions as $index => $value ) {
289
  $fields = array();
290
- $fields['dimension'] = 'dimension' . $index;
291
- $fields['value'] = $value;
292
  $this->add( 'set', $fields );
293
  }
294
  }
@@ -323,13 +341,6 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
323
  do_action( 'gadwp_analytics_commands', $this );
324
  }
325
 
326
- /**
327
- * Outputs the Google Optimize tracking code
328
- */
329
- public function optimize_output() {
330
- GADWP_Tools::load_view( 'front/views/optimize-code.php', array( 'containerid' => $this->gadwp->config->options['optimize_containerid'] ) );
331
- }
332
-
333
  /**
334
  * Outputs the Google Analytics tracking code
335
  */
@@ -345,7 +356,11 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
345
 
346
  $fields = '';
347
  foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
348
- $fieldvalue = $this->filter( $fieldvalue );
 
 
 
 
349
  $fields .= ", " . $fieldvalue;
350
  }
351
 
@@ -370,7 +385,144 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
370
  GADWP_Tools::load_view( 'front/views/analytics-optout-code.php', array( 'uaid' => $this->uaid, 'gaDntOptout' => $this->gadwp->config->options['ga_dnt_optout'], 'gaOptout' => $this->gadwp->config->options['ga_optout'] ) );
371
  }
372
 
373
- GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode, 'tracking_script_path' => $tracking_script_path ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  }
375
  }
376
  }
@@ -530,7 +682,7 @@ if ( ! class_exists( 'GADWP_Tracking_Analytics_AMP' ) ) {
530
  /* @formatter:on */
531
 
532
  // Set Custom Dimensions as extraUrlParams
533
- $custom_dimensions = $this->bulid_custom_dimensions();
534
 
535
  if ( ! empty( $custom_dimensions ) ) {
536
  foreach ( $custom_dimensions as $index => $value ) {
27
  $this->uaid = esc_html( $profile[2] );
28
  }
29
 
30
+ protected function build_custom_dimensions() {
31
  $custom_dimensions = array();
32
 
33
  if ( $this->gadwp->config->options['ga_author_dimindex'] && ( is_single() || is_page() ) ) {
107
  }
108
  }
109
 
110
+ if ( ! class_exists( 'GADWP_Tracking_Analytics_Common' ) ) {
111
 
112
+ class GADWP_Tracking_Analytics_Common extends GADWP_Tracking_Analytics_Base {
113
 
114
+ protected $commands;
115
 
116
  public function __construct() {
117
  parent::__construct();
121
  if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_pagehiding'] && $this->gadwp->config->options['optimize_containerid'] ) {
122
  add_action( 'wp_head', array( $this, 'optimize_output' ), 99 );
123
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  /**
151
  'event_precision' => $this->gadwp->config->options['ga_event_precision'],
152
  'event_formsubmit' => $this->gadwp->config->options ['ga_formsubmit_tracking'],
153
  'ga_pagescrolldepth_tracking' => $this->gadwp->config->options['ga_pagescrolldepth_tracking'],
154
+ 'ga_with_gtag' => $this->gadwp->config->options ['ga_with_gtag'],
155
  ),
156
  )
157
  );
160
  }
161
 
162
  /**
163
+ * Outputs the Google Optimize tracking code
 
 
 
164
  */
165
+ public function optimize_output() {
166
+ GADWP_Tools::load_view( 'front/views/optimize-code.php', array( 'containerid' => $this->gadwp->config->options['optimize_containerid'] ) );
167
  }
168
 
169
  /**
171
  * @param string $value
172
  * @return string
173
  */
174
+ protected function filter( $value, $is_dim = false ) {
175
+ if ( 'true' == $value || 'false' == $value || ( is_numeric( $value ) && ! $is_dim ) ) {
176
  return $value;
177
  }
178
 
179
+ if ( substr( $value, 0, 1 ) == '[' && substr( $value, - 1 ) == ']' || substr( $value, 0, 1 ) == '{' && substr( $value, - 1 ) == '}' ) {
180
  return $value;
181
  }
182
 
183
  return "'" . $value . "'";
184
  }
185
 
186
+ /**
187
+ * Retrieves the commands
188
+ */
189
+ public function get() {
190
+ return $this->commands;
191
+ }
192
+
193
+ /**
194
+ * Stores the commands
195
+ * @param array $commands
196
+ */
197
+ public function set( $commands ) {
198
+ $this->commands = $commands;
199
+ }
200
+
201
+ /**
202
+ * Formats the command before being added to the commands
203
+ * @param string $command
204
+ * @param array $fields
205
+ * @param string $fieldsobject
206
+ * @return array
207
+ */
208
+ public function prepare( $command, $fields, $fieldsobject = null ) {
209
+ return array( 'command' => $command, 'fields' => $fields, 'fieldsobject' => $fieldsobject );
210
+ }
211
+
212
+ /**
213
+ * Adds a formatted command to commands
214
+ * @param string $command
215
+ * @param array $fields
216
+ * @param string $fieldsobject
217
+ */
218
+ protected function add( $command, $fields, $fieldsobject = null ) {
219
+ $this->commands[] = $this->prepare( $command, $fields, $fieldsobject );
220
+ }
221
+ }
222
+ }
223
+
224
+ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
225
+
226
+ class GADWP_Tracking_Analytics extends GADWP_Tracking_Analytics_Common {
227
+
228
+ public function __construct() {
229
+ parent::__construct();
230
+
231
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
232
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
233
+ } else {
234
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
235
+ }
236
+ }
237
+
238
  /**
239
  * Builds the commands based on user's options
240
  */
301
  $this->add( 'set', $fields );
302
  }
303
 
304
+ $custom_dimensions = $this->build_custom_dimensions();
305
  if ( ! empty( $custom_dimensions ) ) {
306
  foreach ( $custom_dimensions as $index => $value ) {
307
  $fields = array();
308
+ $fields['gadwp_dimension'] = 'dimension' . $index;
309
+ $fields['gadwp_dim_value'] = $value;
310
  $this->add( 'set', $fields );
311
  }
312
  }
341
  do_action( 'gadwp_analytics_commands', $this );
342
  }
343
 
 
 
 
 
 
 
 
344
  /**
345
  * Outputs the Google Analytics tracking code
346
  */
356
 
357
  $fields = '';
358
  foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
359
+ if ( false === strpos( $fieldkey, 'gadwp_dim_value' ) ) {
360
+ $fieldvalue = $this->filter( $fieldvalue );
361
+ } else {
362
+ $fieldvalue = $this->filter( $fieldvalue, true );
363
+ }
364
  $fields .= ", " . $fieldvalue;
365
  }
366
 
385
  GADWP_Tools::load_view( 'front/views/analytics-optout-code.php', array( 'uaid' => $this->uaid, 'gaDntOptout' => $this->gadwp->config->options['ga_dnt_optout'], 'gaOptout' => $this->gadwp->config->options['ga_optout'] ) );
386
  }
387
 
388
+ GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode, 'tracking_script_path' => $tracking_script_path, 'ga_with_gtag' => $this->gadwp->config->options['ga_with_gtag'] , 'uaid' => $this->uaid ) );
389
+ }
390
+ }
391
+ }
392
+
393
+
394
+ if ( ! class_exists( 'GADWP_Tracking_GlobalSiteTag' ) ) {
395
+
396
+ class GADWP_Tracking_GlobalSiteTag extends GADWP_Tracking_Analytics_Common {
397
+
398
+ public function __construct() {
399
+ parent::__construct();
400
+
401
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
402
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
403
+ } else {
404
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Builds the commands based on user's options
410
+ */
411
+ private function build_commands() {
412
+ $fields = array();
413
+ $fieldsobject = array();
414
+ $fields['trackingId'] = $this->uaid;
415
+ $custom_dimensions = $this->build_custom_dimensions();
416
+ /*
417
+ * if ( 1 != $this->gadwp->config->options['ga_speed_samplerate'] ) {
418
+ * $fieldsobject['siteSpeedSampleRate'] = (int) $this->gadwp->config->options['ga_speed_samplerate'];
419
+ * }
420
+ */
421
+ if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
422
+ $fieldsobject['cookie_domain'] = $this->gadwp->config->options['ga_cookiedomain'];
423
+ }
424
+ if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
425
+ $fieldsobject['cookie_name'] = $this->gadwp->config->options['ga_cookiename'];
426
+ }
427
+ if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
428
+ $fieldsobject['cookie_expires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
429
+ }
430
+ /*
431
+ * if ( $this->gadwp->config->options['amp_tracking_clientidapi'] ) {
432
+ * $fieldsobject['useAmpClientId'] = 'true';
433
+ * }
434
+ */
435
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
436
+ $domains = '';
437
+ $domains = explode( ',', $this->gadwp->config->options['ga_crossdomain_list'] );
438
+ $domains = array_map( 'trim', $domains );
439
+ $domains = strip_tags( implode( "','", $domains ) );
440
+ $domains = "['" . $domains . "']";
441
+ $fieldsobject['linker'] = "{ 'domains' : " . $domains . " }";
442
+ }
443
+ if ( ! $this->gadwp->config->options['ga_remarketing'] ) {
444
+ $fieldsobject['allow_display_features'] = 'false';
445
+ }
446
+ if ( $this->gadwp->config->options['ga_enhanced_links'] ) {
447
+ $fieldsobject['link_attribution'] = 'true';
448
+ }
449
+ if ( $this->gadwp->config->options['ga_anonymize_ip'] ) {
450
+ $fieldsobject['anonymize_ip'] = 'true';
451
+ }
452
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_containerid'] ) {
453
+ $fieldsobject['optimize_id'] = esc_attr( $this->gadwp->config->options['optimize_containerid'] );
454
+ }
455
+ if ( 100 != $this->gadwp->config->options['ga_user_samplerate'] ) {
456
+ $fieldsobject['sample_rate'] = (int) $this->gadwp->config->options['ga_user_samplerate'];
457
+ }
458
+ if ( ! empty( $custom_dimensions ) ) {
459
+ $fieldsobject['custom_map'] = "{\n\t\t";
460
+ foreach ( $custom_dimensions as $index => $value ) {
461
+ $fieldsobject['custom_map'] .= "'dimension" . $index . "': '" . "gadwp_dim_" . $index . "', \n\t\t";
462
+ }
463
+ $fieldsobject['custom_map'] = rtrim( $fieldsobject['custom_map'], ", \n\t\t" );
464
+ $fieldsobject['custom_map'] .= "\n\t}";
465
+ }
466
+ $this->add( 'config', $fields, $fieldsobject );
467
+
468
+ if ( ! empty( $custom_dimensions ) ) {
469
+ $fields = array();
470
+ $fieldsobject = array();
471
+ $fields['event_name'] = 'gadwp_dimensions';
472
+ foreach ( $custom_dimensions as $index => $value ) {
473
+ $fieldsobject['gadwp_dim_' . $index] = $value;
474
+ }
475
+ $this->add( 'event', $fields, $fieldsobject );
476
+ }
477
+
478
+ do_action( 'gadwp_analytics_commands', $this );
479
+ }
480
+
481
+ /**
482
+ * Outputs the Google Analytics tracking code
483
+ */
484
+ public function output() {
485
+ $this->commands = array();
486
+
487
+ $this->build_commands();
488
+
489
+ $trackingcode = '';
490
+
491
+ foreach ( $this->commands as $set ) {
492
+ $command = $set['command'];
493
+
494
+ $fields = '';
495
+ foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
496
+ $fieldvalue = $this->filter( $fieldvalue );
497
+ $fields .= ", " . $fieldvalue;
498
+ }
499
+
500
+ if ( $set['fieldsobject'] ) {
501
+ $fieldsobject = ", {\n\t";
502
+ foreach ( $set['fieldsobject'] as $fieldkey => $fieldvalue ) {
503
+ if ( false === strpos( $fieldkey, 'gadwp_' ) ) {
504
+ $fieldvalue = $this->filter( $fieldvalue );
505
+ } else {
506
+ $fieldvalue = $this->filter( $fieldvalue, true );
507
+ }
508
+ $fieldkey = $this->filter( $fieldkey );
509
+ $fieldsobject .= $fieldkey . ": " . $fieldvalue . ", \n\t";
510
+ }
511
+ $fieldsobject = rtrim( $fieldsobject, ", \n\t" );
512
+ $fieldsobject .= "\n }";
513
+ $trackingcode .= " gtag('" . $command . "'" . $fields . $fieldsobject . ");\n";
514
+ } else {
515
+ $trackingcode .= " gtag('" . $command . "'" . $fields . ");\n";
516
+ }
517
+ }
518
+
519
+ $tracking_script_path = apply_filters( 'gadwp_analytics_script_path', 'https://www.googletagmanager.com/gtag/js' );
520
+
521
+ if ( $this->gadwp->config->options['ga_optout'] || $this->gadwp->config->options['ga_dnt_optout'] ) {
522
+ GADWP_Tools::load_view( 'front/views/analytics-optout-code.php', array( 'uaid' => $this->uaid, 'gaDntOptout' => $this->gadwp->config->options['ga_dnt_optout'], 'gaOptout' => $this->gadwp->config->options['ga_optout'] ) );
523
+ }
524
+
525
+ GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode, 'tracking_script_path' => $tracking_script_path, 'ga_with_gtag' => $this->gadwp->config->options['ga_with_gtag'] , 'uaid' => $this->uaid ) );
526
  }
527
  }
528
  }
682
  /* @formatter:on */
683
 
684
  // Set Custom Dimensions as extraUrlParams
685
+ $custom_dimensions = $this->build_custom_dimensions();
686
 
687
  if ( ! empty( $custom_dimensions ) ) {
688
  foreach ( $custom_dimensions as $index => $value ) {
front/tracking-tagmanager.php CHANGED
@@ -22,8 +22,6 @@ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
22
  public function __construct() {
23
  $this->gadwp = GADWP();
24
 
25
- $this->load_scripts();
26
-
27
  if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
28
  add_action( 'wp_footer', array( $this, 'output' ), 99 );
29
  } else {
@@ -36,16 +34,6 @@ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
36
  }
37
  }
38
 
39
- /**
40
- * Styles & Scripts load
41
- */
42
- private function load_scripts() {
43
- if ( $this->gadwp->config->options['tm_pagescrolldepth_tracking'] ) {
44
- wp_enqueue_script( 'gadwp-pagescrolldepth-tracking', GADWP_URL . 'front/js/tracking-scrolldepth.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingcode_infooter'] );
45
- wp_enqueue_script( 'gadwp-tracking-tagmanager-events', GADWP_URL . 'front/js/tracking-tagmanager-events.js', array( 'jquery', 'gadwp-pagescrolldepth-tracking' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingcode_infooter'] );
46
- }
47
- }
48
-
49
  /**
50
  * Retrieves the datalayer variables
51
  */
@@ -73,7 +61,7 @@ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
73
  /**
74
  * Builds the datalayer based on user's options
75
  */
76
- private function build_datalayer() {
77
  global $post;
78
 
79
  if ( $this->gadwp->config->options['tm_author_var'] && ( is_single() || is_page() ) ) {
@@ -134,7 +122,7 @@ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
134
  * Outputs the Google Tag Manager tracking code
135
  */
136
  public function output() {
137
- $this->build_datalayer();
138
 
139
  if ( is_array( $this->datalayer ) ) {
140
  $vars = "{";
@@ -167,7 +155,23 @@ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
167
  * Outputs the Tag Manager code for AMP
168
  */
169
  public function amp_output() {
170
- ?><amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo $this->gadwp->config->options['amp_containerid']; ?>&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
  }
173
  }
22
  public function __construct() {
23
  $this->gadwp = GADWP();
24
 
 
 
25
  if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
26
  add_action( 'wp_footer', array( $this, 'output' ), 99 );
27
  } else {
34
  }
35
  }
36
 
 
 
 
 
 
 
 
 
 
 
37
  /**
38
  * Retrieves the datalayer variables
39
  */
61
  /**
62
  * Builds the datalayer based on user's options
63
  */
64
+ private function build_custom_dimensions() {
65
  global $post;
66
 
67
  if ( $this->gadwp->config->options['tm_author_var'] && ( is_single() || is_page() ) ) {
122
  * Outputs the Google Tag Manager tracking code
123
  */
124
  public function output() {
125
+ $this->build_custom_dimensions();
126
 
127
  if ( is_array( $this->datalayer ) ) {
128
  $vars = "{";
155
  * Outputs the Tag Manager code for AMP
156
  */
157
  public function amp_output() {
158
+
159
+ $this->build_custom_dimensions();
160
+
161
+ $vars = array( 'vars' => $this->datalayer );
162
+
163
+ if ( version_compare( phpversion(), '5.4.0', '<' ) ) {
164
+ $json = json_encode( $vars );
165
+ } else {
166
+ $json = json_encode( $vars, JSON_PRETTY_PRINT );
167
+ }
168
+
169
+ $amp_containerid = $this->gadwp->config->options['amp_containerid'];
170
+
171
+ $json = str_replace( array( '"&#91;', '&#93;"' ), array( '[', ']' ), $json ); // make verticalBoundaries a JavaScript array
172
+
173
+ GADWP_Tools::load_view( 'front/views/tagmanager-amp-code.php', array ( 'json' => $json, 'containerid' => $amp_containerid ) );
174
+
175
  }
176
  }
177
  }
front/tracking.php CHANGED
@@ -43,12 +43,16 @@ if ( ! class_exists( 'GADWP_Tracking' ) ) {
43
 
44
  // Analytics
45
  require_once 'tracking-analytics.php';
46
- $this->analytics = new GADWP_Tracking_Analytics();
 
 
 
 
 
47
 
48
  if ( $this->gadwp->config->options['amp_tracking_analytics'] ) {
49
  $this->analytics_amp = new GADWP_Tracking_Analytics_AMP();
50
  }
51
-
52
  }
53
 
54
  if ( 'tagmanager' == $this->gadwp->config->options['tracking_type'] && $this->gadwp->config->options['web_containerid'] ) {
43
 
44
  // Analytics
45
  require_once 'tracking-analytics.php';
46
+
47
+ if ( 1 == $this->gadwp->config->options['ga_with_gtag'] ) {
48
+ $this->analytics = new GADWP_Tracking_GlobalSiteTag();
49
+ } else {
50
+ $this->analytics = new GADWP_Tracking_Analytics();
51
+ }
52
 
53
  if ( $this->gadwp->config->options['amp_tracking_analytics'] ) {
54
  $this->analytics_amp = new GADWP_Tracking_Analytics_AMP();
55
  }
 
56
  }
57
 
58
  if ( 'tagmanager' == $this->gadwp->config->options['tracking_type'] && $this->gadwp->config->options['web_containerid'] ) {
front/views/analytics-code.php CHANGED
@@ -7,6 +7,8 @@
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
9
  ?>
 
 
10
  <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Universal Analytics - https://deconf.com/google-analytics-dashboard-wordpress/ -->
11
  <script>
12
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -16,3 +18,23 @@
16
  <?php echo $data['trackingcode']?>
17
  </script>
18
  <!-- END GADWP Universal Analytics -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
9
  ?>
10
+
11
+ <?php if ( 0 == $data['ga_with_gtag'] ):?>
12
  <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Universal Analytics - https://deconf.com/google-analytics-dashboard-wordpress/ -->
13
  <script>
14
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
18
  <?php echo $data['trackingcode']?>
19
  </script>
20
  <!-- END GADWP Universal Analytics -->
21
+ <?php else:?>
22
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Global Site Tag - https://deconf.com/google-analytics-dashboard-wordpress/ -->
23
+ <script async src="<?php echo $data['tracking_script_path']?>?id=<?php echo $data['uaid']?>"></script>
24
+ <script>
25
+ window.dataLayer = window.dataLayer || [];
26
+ function gtag(){dataLayer.push(arguments);}
27
+ gtag('js', new Date());
28
+ <?php echo $data['trackingcode']?>
29
+
30
+ if (window.performance) {
31
+ var timeSincePageLoad = Math.round(performance.now());
32
+ gtag('event', 'timing_complete', {
33
+ 'name': 'load',
34
+ 'value': timeSincePageLoad,
35
+ 'event_category': 'JS Dependencies'
36
+ });
37
+ }
38
+ </script>
39
+ <!-- END GADWP Global Site Tag -->
40
+ <?php endif;?>
front/views/tagmanager-amp-code.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2018 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo $data['containerid']; ?>&gtm.url=SOURCE_URL" data-credentials="include">
11
+ <script type="application/json">
12
+ <?php echo $data['json']; ?>
13
+ </script>
14
+ </amp-analytics>
gadwp.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
- * Version: 5.2.3.1
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) )
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
- define( 'GADWP_CURRENT_VERSION', '5.2.3.1' );
20
  }
21
 
22
  if ( ! defined( 'GADWP_ENDPOINT_URL' ) ) {
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
+ * Version: 5.3
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
+ define( 'GADWP_CURRENT_VERSION', '5.3' );
20
  }
21
 
22
  if ( ! defined( 'GADWP_ENDPOINT_URL' ) ) {
install/install.php CHANGED
@@ -87,6 +87,7 @@ class GADWP_Install {
87
  $options['with_endpoint'] = 1;
88
  $options['ga_optout'] = 0;
89
  $options['ga_dnt_optout'] = 0;
 
90
  } else {
91
  $options = array();
92
  $options['client_id'] = get_option( 'ga_dash_clientid' );
@@ -159,6 +160,7 @@ class GADWP_Install {
159
  $options['with_endpoint'] = 1;
160
  $options['ga_optout'] = 0;
161
  $options['ga_dnt_optout'] = 0;
 
162
 
163
  delete_option( 'ga_dash_clientid' );
164
  delete_option( 'ga_dash_clientsecret' );
87
  $options['with_endpoint'] = 1;
88
  $options['ga_optout'] = 0;
89
  $options['ga_dnt_optout'] = 0;
90
+ $options['ga_with_gtag'] = 0;
91
  } else {
92
  $options = array();
93
  $options['client_id'] = get_option( 'ga_dash_clientid' );
160
  $options['with_endpoint'] = 1;
161
  $options['ga_optout'] = 0;
162
  $options['ga_dnt_optout'] = 0;
163
+ $options['ga_with_gtag'] = 0;
164
 
165
  delete_option( 'ga_dash_clientid' );
166
  delete_option( 'ga_dash_clientsecret' );
readme.txt CHANGED
@@ -4,7 +4,8 @@ Donate link: https://deconf.com/donate/
4
  Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
5
  Requires at least: 3.5
6
  Tested up to: 4.9.4
7
- Stable tag: 5.2.3.1
 
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -40,8 +41,8 @@ In addition, you can control who can view specific Google Analytics reports by s
40
 
41
  Installs the latest Google Analytics tracking code and allows full code customization:
42
 
43
- - Universal Google Analytics tracking code
44
- - IP address anonymization
45
  - Enhanced link attribution
46
  - Remarketing, demographics and interests tracking
47
  - Page Speed sampling rate control
@@ -51,6 +52,12 @@ Installs the latest Google Analytics tracking code and allows full code customiz
51
  - Accelerated Mobile Pages (AMP) support for Google Analytics
52
  - Ecommerce support for Google Analytics
53
 
 
 
 
 
 
 
54
  Google Analytics Dashboard for WP enables you to easily track events like:
55
 
56
  - Downloads
@@ -79,7 +86,6 @@ As an alternative to Google Analytics tracking code, you can use Google Tag Mana
79
 
80
  - Google Tag Manager code
81
  - Data Layer variables: authors, publication year, publication month, categories, tags, user type
82
- - Additional Data Layer variables for page scrolling depth
83
  - Exclude user roles from tracking
84
  - Accelerated Mobile Pages (AMP) support for Google Tag Manager
85
 
@@ -165,6 +171,16 @@ Google Analytics Dashboard for WP it's released under the GPLv2, you can use it
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
 
 
 
 
 
168
  = 5.2.3.1 =
169
  * Bug Fixes:
170
  * fixing a small reporting issue
4
  Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
5
  Requires at least: 3.5
6
  Tested up to: 4.9.4
7
+ Stable tag: 5.3
8
+ Requires PHP: 5.2.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
41
 
42
  Installs the latest Google Analytics tracking code and allows full code customization:
43
 
44
+ - Universal Google Analytics (analytics.js) tracking code
45
+ - Global Site Tag (gtag.js) tracking code
46
  - Enhanced link attribution
47
  - Remarketing, demographics and interests tracking
48
  - Page Speed sampling rate control
52
  - Accelerated Mobile Pages (AMP) support for Google Analytics
53
  - Ecommerce support for Google Analytics
54
 
55
+ User privacy oriented features:
56
+
57
+ - IP address anonymization
58
+ - option to follow Do Not Track (DNT) sent by browsers
59
+ - support for user tracking opt-out
60
+
61
  Google Analytics Dashboard for WP enables you to easily track events like:
62
 
63
  - Downloads
86
 
87
  - Google Tag Manager code
88
  - Data Layer variables: authors, publication year, publication month, categories, tags, user type
 
89
  - Exclude user roles from tracking
90
  - Accelerated Mobile Pages (AMP) support for Google Tag Manager
91
 
171
 
172
  == Changelog ==
173
 
174
+ = 5.3 =
175
+ * [release notes](https://deconf.com/adding-gtag-js-to-your-site/)
176
+ * Enhancements:
177
+ * adds full support for Global Site Tag (gtag.js)
178
+ * remove Scroll Depth functionality, since this is now available as a trigger on Google Tag Manager
179
+ * adds custom dimensions support for AMP pages with Google Tag Manager tracking
180
+ * adds support for button submits
181
+ * Bug Fixes:
182
+ * form submit events were not following the non-interaction settings
183
+
184
  = 5.2.3.1 =
185
  * Bug Fixes:
186
  * fixing a small reporting issue