GA Google Analytics - Version 20200815

Version Description

To upgrade GA Google Analytics, remove the old version and replace with the new version. Or just click "Update" from the Plugins screen and let WordPress do it for you automatically.

Note: uninstalling the plugin from the WP Plugins screen results in the removal of all settings from the WP database.

For more information, visit the GA Plugin Homepage.

Download this release

Release Info

Developer specialk
Plugin Icon 128x128 GA Google Analytics
Version 20200815
Comparing to
See all releases

Code changes from version 20200325 to 20200815

ga-google-analytics.php CHANGED
@@ -9,9 +9,9 @@
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.1
12
- Tested up to: 5.4
13
- Stable tag: 20200325
14
- Version: 20200325
15
  Requires PHP: 5.6.20
16
  Text Domain: ga-google-analytics
17
  Domain Path: /languages
@@ -60,7 +60,7 @@ if (!class_exists('GA_Google_Analytics')) {
60
 
61
  function constants() {
62
 
63
- if (!defined('GAP_VERSION')) define('GAP_VERSION', '20200325');
64
  if (!defined('GAP_REQUIRE')) define('GAP_REQUIRE', '4.1');
65
  if (!defined('GAP_AUTHOR')) define('GAP_AUTHOR', 'Jeff Starr');
66
  if (!defined('GAP_NAME')) define('GAP_NAME', __('GA Google Analytics', 'ga-google-analytics'));
@@ -320,6 +320,17 @@ if (!class_exists('GA_Google_Analytics')) {
320
 
321
  $input['gap_id'] = wp_filter_nohtml_kses($input['gap_id']);
322
 
 
 
 
 
 
 
 
 
 
 
 
323
  if (!isset($input['gap_location'])) $input['gap_location'] = null;
324
  if (!array_key_exists($input['gap_location'], $this->options_locations())) $input['gap_location'] = null;
325
 
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.1
12
+ Tested up to: 5.5
13
+ Stable tag: 20200815
14
+ Version: 20200815
15
  Requires PHP: 5.6.20
16
  Text Domain: ga-google-analytics
17
  Domain Path: /languages
60
 
61
  function constants() {
62
 
63
+ if (!defined('GAP_VERSION')) define('GAP_VERSION', '20200815');
64
  if (!defined('GAP_REQUIRE')) define('GAP_REQUIRE', '4.1');
65
  if (!defined('GAP_AUTHOR')) define('GAP_AUTHOR', 'Jeff Starr');
66
  if (!defined('GAP_NAME')) define('GAP_NAME', __('GA Google Analytics', 'ga-google-analytics'));
320
 
321
  $input['gap_id'] = wp_filter_nohtml_kses($input['gap_id']);
322
 
323
+ if (preg_match("/^GTM-/i", $input['gap_id'])) {
324
+
325
+ $input['gap_id'] = '';
326
+
327
+ $message = esc_html__('Error: your tracking code begins with', 'ga-google-analytics') .' <code>GTM-</code> ';
328
+ $message .= esc_html__('(for Google Tag Manager), which is not supported. Please try again with a supported tracking code.', 'ga-google-analytics');
329
+
330
+ add_settings_error('gap_id', 'invalid-tracking-code', $message, 'error');
331
+
332
+ }
333
+
334
  if (!isset($input['gap_location'])) $input['gap_location'] = null;
335
  if (!array_key_exists($input['gap_location'], $this->options_locations())) $input['gap_location'] = null;
336
 
inc/plugin-core.php CHANGED
@@ -72,9 +72,11 @@ function ga_google_analytics_tracking_code() {
72
 
73
  }
74
 
75
-
76
-
77
-
 
 
78
 
79
  function ga_google_analytics_universal() {
80
 
@@ -89,14 +91,17 @@ function ga_google_analytics_universal() {
89
  $ga_anon = "ga('set', 'anonymizeIp', true);";
90
  $ga_ssl = "ga('set', 'forceSSL', true);";
91
 
 
 
92
  ?>
93
 
94
- <script>
 
95
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
96
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
97
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
98
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
99
- ga('create', '<?php echo $tracking_id; ?>'<?php echo $auto; if ($tracker_object) echo ', '. $tracker_object; ?>);
100
  <?php
101
  if ($custom_code) echo $custom_code . "\n\t\t\t";
102
  if ($display_ads) echo $ga_display . "\n\t\t\t";
@@ -110,26 +115,26 @@ function ga_google_analytics_universal() {
110
 
111
  }
112
 
113
-
114
-
115
-
116
-
117
-
118
  function ga_google_analytics_global() {
119
 
120
  extract(ga_google_analytics_options());
121
 
122
  $custom_code = ga_google_analytics_custom_code($custom_code);
123
 
 
 
 
 
124
  ?>
125
 
126
- <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $tracking_id; ?>"></script>
127
- <script>
 
128
  window.dataLayer = window.dataLayer || [];
129
  function gtag(){dataLayer.push(arguments);}
130
  gtag('js', new Date());
131
  <?php if ($custom_code) echo $custom_code . "\n\t\t\t";
132
- ?>gtag('config', '<?php echo $tracking_id; ?>'<?php if ($tracker_object) echo ', '. $tracker_object; ?>);
133
  </script>
134
 
135
  <?php
@@ -150,9 +155,12 @@ function ga_google_analytics_legacy() {
150
 
151
  if ($display_ads) $ga_src = $ga_alt;
152
 
 
 
153
  ?>
154
 
155
- <script type="text/javascript">
 
156
  var _gaq = _gaq || [];
157
  <?php
158
  if ($link_attr) echo $ga_link . "\n\t\t\t";
@@ -182,11 +190,11 @@ function ga_google_analytics_custom_code($custom_code) {
182
 
183
  $code = preg_replace("/%%userid%%/i", get_current_user_id(), $code);
184
 
185
- $custom_code .= "\t\t\t" . trim($code) . "\n";
186
 
187
  }
188
 
189
- $custom_code = trim($custom_code);
190
 
191
  return apply_filters('gap_custom_code', $custom_code);
192
 
72
 
73
  }
74
 
75
+ function ga_google_analytics_credit() {
76
+
77
+ return '<!-- GA Google Analytics @ https://m0n.co/ga -->' ."\n";
78
+
79
+ }
80
 
81
  function ga_google_analytics_universal() {
82
 
91
  $ga_anon = "ga('set', 'anonymizeIp', true);";
92
  $ga_ssl = "ga('set', 'forceSSL', true);";
93
 
94
+ $script_atts = apply_filters('ga_google_analytics_script_atts', '');
95
+
96
  ?>
97
 
98
+ <?php echo ga_google_analytics_credit(); ?>
99
+ <script<?php echo esc_attr($script_atts); ?>>
100
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
101
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
102
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
103
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
104
+ ga('create', '<?php echo $tracking_id; ?>'<?php echo $auto; if ($tracker_object) echo ', '. stripslashes(rtrim($tracker_object)); ?>);
105
  <?php
106
  if ($custom_code) echo $custom_code . "\n\t\t\t";
107
  if ($display_ads) echo $ga_display . "\n\t\t\t";
115
 
116
  }
117
 
 
 
 
 
 
118
  function ga_google_analytics_global() {
119
 
120
  extract(ga_google_analytics_options());
121
 
122
  $custom_code = ga_google_analytics_custom_code($custom_code);
123
 
124
+ $script_atts_ext = apply_filters('ga_google_analytics_script_atts_ext', ' async');
125
+
126
+ $script_atts = apply_filters('ga_google_analytics_script_atts', '');
127
+
128
  ?>
129
 
130
+ <?php echo ga_google_analytics_credit(); ?>
131
+ <script<?php echo esc_attr($script_atts_ext); ?> src="https://www.googletagmanager.com/gtag/js?id=<?php echo $tracking_id; ?>"></script>
132
+ <script<?php echo esc_attr($script_atts); ?>>
133
  window.dataLayer = window.dataLayer || [];
134
  function gtag(){dataLayer.push(arguments);}
135
  gtag('js', new Date());
136
  <?php if ($custom_code) echo $custom_code . "\n\t\t\t";
137
+ ?>gtag('config', '<?php echo $tracking_id; ?>'<?php if ($tracker_object) echo ', '. stripslashes(rtrim($tracker_object)); ?>);
138
  </script>
139
 
140
  <?php
155
 
156
  if ($display_ads) $ga_src = $ga_alt;
157
 
158
+ $script_atts = apply_filters('ga_google_analytics_script_atts', '');
159
+
160
  ?>
161
 
162
+ <?php echo ga_google_analytics_credit(); ?>
163
+ <script<?php echo esc_attr($script_atts); ?> type="text/javascript">
164
  var _gaq = _gaq || [];
165
  <?php
166
  if ($link_attr) echo $ga_link . "\n\t\t\t";
190
 
191
  $code = preg_replace("/%%userid%%/i", get_current_user_id(), $code);
192
 
193
+ $custom_code .= "\t\t\t" . rtrim($code) . "\n";
194
 
195
  }
196
 
197
+ $custom_code = stripslashes(trim($custom_code));
198
 
199
  return apply_filters('gap_custom_code', $custom_code);
200
 
inc/settings-display.php CHANGED
@@ -106,7 +106,7 @@ if (!function_exists('add_action')) die(); ?>
106
  <table class="widefat">
107
  <tr>
108
  <th><label for="gap_options[gap_id]"><?php esc_html_e('GA Tracking ID', 'ga-google-analytics') ?></label></th>
109
- <td><input id="gap_options[gap_id]" name="gap_options[gap_id]" type="text" size="20" maxlength="22" value="<?php if (isset($gap_options['gap_id'])) echo esc_attr($gap_options['gap_id']); ?>"></td>
110
  </tr>
111
  <tr>
112
  <th><label for="gap_options[gap_enable]"><?php esc_html_e('Tracking Method', 'ga-google-analytics') ?></label></th>
106
  <table class="widefat">
107
  <tr>
108
  <th><label for="gap_options[gap_id]"><?php esc_html_e('GA Tracking ID', 'ga-google-analytics') ?></label></th>
109
+ <td><input id="gap_options[gap_id]" name="gap_options[gap_id]" type="text" size="30" maxlength="30" value="<?php if (isset($gap_options['gap_id'])) echo esc_attr($gap_options['gap_id']); ?>"></td>
110
  </tr>
111
  <tr>
112
  <th><label for="gap_options[gap_enable]"><?php esc_html_e('Tracking Method', 'ga-google-analytics') ?></label></th>
languages/ga-google-analytics.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: GA Google Analytics\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2019-11-09 21:39+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
  "Language-Team: \n"
@@ -88,43 +88,53 @@ msgstr ""
88
  msgid "Cheatin&rsquo; huh?"
89
  msgstr ""
90
 
91
- #: ga-google-analytics.php:366
 
 
 
 
 
 
 
 
 
 
92
  msgid "Include tracking code in page head (via"
93
  msgstr ""
94
 
95
- #: ga-google-analytics.php:366 ga-google-analytics.php:370
96
  msgid ")"
97
  msgstr ""
98
 
99
- #: ga-google-analytics.php:370
100
  msgid "Include tracking code in page footer (via"
101
  msgstr ""
102
 
103
- #: ga-google-analytics.php:382 inc/settings-display.php:75
104
  msgid "Universal Analytics"
105
  msgstr ""
106
 
107
- #: ga-google-analytics.php:383 inc/settings-display.php:76
108
  msgid "Global Site Tag"
109
  msgstr ""
110
 
111
- #: ga-google-analytics.php:384
112
  msgid "Legacy"
113
  msgstr ""
114
 
115
- #: ga-google-analytics.php:390
116
  msgid "(default)"
117
  msgstr ""
118
 
119
- #: ga-google-analytics.php:394
120
  msgid "(new method)"
121
  msgstr ""
122
 
123
- #: ga-google-analytics.php:398
124
  msgid "(deprecated)"
125
  msgstr ""
126
 
127
- #: ga-google-analytics.php:461
128
  msgid "Restore default plugin options"
129
  msgstr ""
130
 
3
  msgstr ""
4
  "Project-Id-Version: GA Google Analytics\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2020-08-15 23:01+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
  "Language-Team: \n"
88
  msgid "Cheatin&rsquo; huh?"
89
  msgstr ""
90
 
91
+ #: ga-google-analytics.php:327
92
+ msgid "Error: your tracking code begins with"
93
+ msgstr ""
94
+
95
+ #: ga-google-analytics.php:328
96
+ msgid ""
97
+ "(for Google Tag Manager), which is not supported. Please try again with a "
98
+ "supported tracking code."
99
+ msgstr ""
100
+
101
+ #: ga-google-analytics.php:377
102
  msgid "Include tracking code in page head (via"
103
  msgstr ""
104
 
105
+ #: ga-google-analytics.php:377 ga-google-analytics.php:381
106
  msgid ")"
107
  msgstr ""
108
 
109
+ #: ga-google-analytics.php:381
110
  msgid "Include tracking code in page footer (via"
111
  msgstr ""
112
 
113
+ #: ga-google-analytics.php:393 inc/settings-display.php:75
114
  msgid "Universal Analytics"
115
  msgstr ""
116
 
117
+ #: ga-google-analytics.php:394 inc/settings-display.php:76
118
  msgid "Global Site Tag"
119
  msgstr ""
120
 
121
+ #: ga-google-analytics.php:395
122
  msgid "Legacy"
123
  msgstr ""
124
 
125
+ #: ga-google-analytics.php:401
126
  msgid "(default)"
127
  msgstr ""
128
 
129
+ #: ga-google-analytics.php:405
130
  msgid "(new method)"
131
  msgstr ""
132
 
133
+ #: ga-google-analytics.php:409
134
  msgid "(deprecated)"
135
  msgstr ""
136
 
137
+ #: ga-google-analytics.php:472
138
  msgid "Restore default plugin options"
139
  msgstr ""
140
 
readme.txt CHANGED
@@ -9,9 +9,9 @@ Author URI: https://plugin-planet.com/
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.1
12
- Tested up to: 5.4
13
- Stable tag: 20200325
14
- Version: 20200325
15
  Requires PHP: 5.6.20
16
  Text Domain: ga-google-analytics
17
  Domain Path: /languages
@@ -42,6 +42,7 @@ This plugin enables Google Analytics for your entire WordPress site. Lightweight
42
  * Sleek plugin Settings page with toggling panels
43
  * Option to disable tracking of admin-level users
44
  * Option to enable page tracking in the Admin Area
 
45
  * Easy to customize the tracking code
46
  * More features available in the [Pro version](https://plugin-planet.com/ga-google-analytics-pro/)
47
 
@@ -92,9 +93,6 @@ __Cookies:__ This plugin uses simple cookies for the visitor Opt-Out Box to reme
92
  __Services:__ This plugin does not connect to any third-party locations or services, but it does enable Google to collect all sorts of data.
93
 
94
 
95
- > Works with or without Gutenberg Block Editor
96
-
97
-
98
 
99
  == Installation ==
100
 
@@ -107,7 +105,7 @@ After configuring your settings, you can verify that GA tracking code is include
107
 
108
  __Note:__ this plugin adds the required GA code to your web pages. In order for the code to do anything, it must correspond to an active, properly configured Google Analytics account. Learn more at the [Google Analytics Help Center](https://support.google.com/analytics/?hl=en#topic=3544906).
109
 
110
- [More info on installing WP plugins](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
111
 
112
 
113
  **Usage**
@@ -229,6 +227,31 @@ Done! You can view the source code of your web pages to verify the results.
229
  More info about [user opt-out](https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out).
230
 
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  **Got a question?**
233
 
234
  To ask a question, suggest a feature, or provide feedback, [contact me directly](https://perishablepress.com/contact/). Learn more about [Google Analytics](https://www.google.com/analytics/) and [GA tracking methods](https://perishablepress.com/3-ways-track-google-analytics/).
@@ -265,6 +288,18 @@ If you like GA Google Analytics, please take a moment to [give a 5-star rating](
265
  > New Pro version available! Check out [GA Pro &raquo;](https://plugin-planet.com/ga-google-analytics-pro/)
266
 
267
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  **20200325**
269
 
270
  * Fixes bug with `auto` parameter
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.1
12
+ Tested up to: 5.5
13
+ Stable tag: 20200815
14
+ Version: 20200815
15
  Requires PHP: 5.6.20
16
  Text Domain: ga-google-analytics
17
  Domain Path: /languages
42
  * Sleek plugin Settings page with toggling panels
43
  * Option to disable tracking of admin-level users
44
  * Option to enable page tracking in the Admin Area
45
+ * Works with or without Gutenberg Block Editor
46
  * Easy to customize the tracking code
47
  * More features available in the [Pro version](https://plugin-planet.com/ga-google-analytics-pro/)
48
 
93
  __Services:__ This plugin does not connect to any third-party locations or services, but it does enable Google to collect all sorts of data.
94
 
95
 
 
 
 
96
 
97
  == Installation ==
98
 
105
 
106
  __Note:__ this plugin adds the required GA code to your web pages. In order for the code to do anything, it must correspond to an active, properly configured Google Analytics account. Learn more at the [Google Analytics Help Center](https://support.google.com/analytics/?hl=en#topic=3544906).
107
 
108
+ [More info on installing WP plugins](https://wordpress.org/support/article/managing-plugins/#installing-plugins)
109
 
110
 
111
  **Usage**
227
  More info about [user opt-out](https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out).
228
 
229
 
230
+ **How to disable the "auto" parameter in ga(create)?**
231
+
232
+ By default the plugin includes the `auto` parameter in the tracking code:
233
+
234
+ ga('create', 'GA-123456789000', 'auto');
235
+
236
+ However some tracking techniques (such as Site Speed Sample Rate) require replacing the `auto` parameter. To do it:
237
+
238
+ First disable the `auto` parameter by adding the following code to WordPress functions or custom plugin:
239
+
240
+ // GA Google Analytics - Disable auto parameter
241
+ function ga_google_analytics_enable_auto($enable) { return false; }
242
+ add_filter('ga_google_analytics_enable_auto', 'ga_google_analytics_enable_auto');
243
+
244
+ Now that `auto` is disabled, you can replace it with your own parameter(s). For example, to implement Universal Analytics Site Speed Sample Rate, enter the following code in the plugin setting "Custom Tracker Objects":
245
+
246
+ {'siteSpeedSampleRate': 100}
247
+
248
+ Save changes and done. The resulting tracking code will now look like this:
249
+
250
+ ga('create', 'GA-123456789000', {'siteSpeedSampleRate': 100});
251
+
252
+ So can adjust things as needed to add any parameters that are required.
253
+
254
+
255
  **Got a question?**
256
 
257
  To ask a question, suggest a feature, or provide feedback, [contact me directly](https://perishablepress.com/contact/). Learn more about [Google Analytics](https://www.google.com/analytics/) and [GA tracking methods](https://perishablepress.com/3-ways-track-google-analytics/).
288
  > New Pro version available! Check out [GA Pro &raquo;](https://plugin-planet.com/ga-google-analytics-pro/)
289
 
290
 
291
+ **20200815**
292
+
293
+ * Adds short URL ID comment to source code
294
+ * Adds filter hook `ga_google_analytics_script_atts`
295
+ * Adds filter hook `ga_google_analytics_script_atts_ext`
296
+ * Adds return error if user enters `GTM-` tracking code
297
+ * Improves sanitization of options output
298
+ * Updates default translation template
299
+ * Refines plugin setting page styles
300
+ * Refines readme/documentation
301
+ * Tests on WordPress 5.5
302
+
303
  **20200325**
304
 
305
  * Fixes bug with `auto` parameter