Version Description
Download this release
Release Info
Developer | ShareThis |
Plugin | Google Analytics |
Version | 2.5.4 |
Comparing to | |
See all releases |
Code changes from version 2.5.3 to 2.5.4
- class/Ga_Helper.php +2 -2
- class/Ga_Stats.php +97 -4
- googleanalytics.php +2 -2
- readme.txt +6 -2
class/Ga_Helper.php
CHANGED
@@ -231,12 +231,12 @@ class Ga_Helper {
|
|
231 |
private static function get_dashboard_widget_data( $date_range, $metric = null ) {
|
232 |
$selected = self::get_selected_account_data( true );
|
233 |
if ( self::is_authorized() && self::is_account_selected() ) {
|
234 |
-
$query_params = Ga_Stats::get_query( 'main_chart', $selected[ 'view_id' ], $date_range, $metric );
|
235 |
$stats_data = Ga_Admin::api_client()->call( 'ga_api_data', array(
|
236 |
$query_params
|
237 |
) );
|
238 |
|
239 |
-
$boxes_query = Ga_Stats::get_query( 'dashboard_boxes', $selected[ 'view_id' ], $date_range );
|
240 |
$boxes_data = Ga_Admin::api_client()->call( 'ga_api_data', array(
|
241 |
$boxes_query
|
242 |
) );
|
231 |
private static function get_dashboard_widget_data( $date_range, $metric = null ) {
|
232 |
$selected = self::get_selected_account_data( true );
|
233 |
if ( self::is_authorized() && self::is_account_selected() ) {
|
234 |
+
$query_params = Ga_Stats::get_query( 'main_chart', $selected[ 'view_id' ], $date_range, $metric, true );
|
235 |
$stats_data = Ga_Admin::api_client()->call( 'ga_api_data', array(
|
236 |
$query_params
|
237 |
) );
|
238 |
|
239 |
+
$boxes_query = Ga_Stats::get_query( 'dashboard_boxes', $selected[ 'view_id' ], $date_range, null, true );
|
240 |
$boxes_data = Ga_Admin::api_client()->call( 'ga_api_data', array(
|
241 |
$boxes_query
|
242 |
) );
|
class/Ga_Stats.php
CHANGED
@@ -28,12 +28,14 @@ class Ga_Stats {
|
|
28 |
* @param int $id_view The Analytics view ID from which to retrieve data.
|
29 |
* @param string $date_range The start date for the query in the format YYYY-MM-DD or '7daysAgo'
|
30 |
* @param string $metric A metric expression
|
|
|
31 |
*
|
32 |
* @return array Request query
|
33 |
*/
|
34 |
-
public static function get_query( $query, $id_view, $date_range = null, $metric = null ) {
|
35 |
if ( $query == 'main_chart' ) {
|
36 |
-
return self::
|
|
|
37 |
} elseif ( $query == 'gender' ) {
|
38 |
return self::gender_chart_query($id_view, $date_range, $metric);
|
39 |
} elseif ( $query == 'device' ) {
|
@@ -43,7 +45,8 @@ class Ga_Stats {
|
|
43 |
} elseif ( $query == 'boxes' ) {
|
44 |
return self::boxes_query( $id_view );
|
45 |
} elseif ( $query == 'dashboard_boxes' ) {
|
46 |
-
return self::
|
|
|
47 |
} elseif ( $query == 'sources' ) {
|
48 |
return self::sources_query( $id_view, $date_range );
|
49 |
} else {
|
@@ -98,7 +101,7 @@ class Ga_Stats {
|
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
-
* Preparing query for
|
102 |
*
|
103 |
* @param int $id_view The Analytics view ID from which to retrieve data.
|
104 |
* @param array $date_ranges An array representing the date ranges that will be passed to chart query.
|
@@ -143,6 +146,56 @@ class Ga_Stats {
|
|
143 |
return $query;
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
/**
|
147 |
* Preparing query for stats boxes
|
148 |
*
|
@@ -205,6 +258,46 @@ class Ga_Stats {
|
|
205 |
return $query;
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
/**
|
209 |
* Preparing query for gender chart
|
210 |
*
|
28 |
* @param int $id_view The Analytics view ID from which to retrieve data.
|
29 |
* @param string $date_range The start date for the query in the format YYYY-MM-DD or '7daysAgo'
|
30 |
* @param string $metric A metric expression
|
31 |
+
* @param bool $old Use old query style.
|
32 |
*
|
33 |
* @return array Request query
|
34 |
*/
|
35 |
+
public static function get_query( $query, $id_view, $date_range = null, $metric = null, $old = false ) {
|
36 |
if ( $query == 'main_chart' ) {
|
37 |
+
return $old ? self::main_chart_query_old($id_view, $date_range, $metric) : self::main_chart_query($id_view,
|
38 |
+
$date_range, $metric);
|
39 |
} elseif ( $query == 'gender' ) {
|
40 |
return self::gender_chart_query($id_view, $date_range, $metric);
|
41 |
} elseif ( $query == 'device' ) {
|
45 |
} elseif ( $query == 'boxes' ) {
|
46 |
return self::boxes_query( $id_view );
|
47 |
} elseif ( $query == 'dashboard_boxes' ) {
|
48 |
+
return $old ? self::dashboard_boxes_query_old( $id_view, $date_range ) :
|
49 |
+
self::dashboard_boxes_query( $id_view, $date_range );
|
50 |
} elseif ( $query == 'sources' ) {
|
51 |
return self::sources_query( $id_view, $date_range );
|
52 |
} else {
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
+
* Preparing query for dashboard boxes
|
105 |
*
|
106 |
* @param int $id_view The Analytics view ID from which to retrieve data.
|
107 |
* @param array $date_ranges An array representing the date ranges that will be passed to chart query.
|
146 |
return $query;
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* Preparing query for dashboard boxes
|
151 |
+
*
|
152 |
+
* @param int $id_view The Analytics view ID from which to retrieve data.
|
153 |
+
* @param string $date_range The start date for the query in the format YYYY-MM-DD or '7daysAgo'
|
154 |
+
*
|
155 |
+
* @return array Dashboard boxes query
|
156 |
+
* @deprecated
|
157 |
+
*
|
158 |
+
*/
|
159 |
+
public static function dashboard_boxes_query_old($id_view, $date_range)
|
160 |
+
{
|
161 |
+
$reports_requests = [];
|
162 |
+
$daysAgo = isset($_GET['th']) ? '30daysAgo' : '7daysAgo';
|
163 |
+
|
164 |
+
if (isset($_GET['ts'])) {
|
165 |
+
$reports_requests[] = [
|
166 |
+
'viewId' => $id_view,
|
167 |
+
'dateRanges' => self::set_date_ranges($daysAgo, 'yesterday'),
|
168 |
+
'metrics' => self::set_metrics(['ga:pageviews']),
|
169 |
+
'includeEmptyRows' => true,
|
170 |
+
'pageSize' => 10,
|
171 |
+
'dimensions' => self::set_dimensions('ga:sourceMedium'),
|
172 |
+
'orderBys' => self::set_order_bys('ga:pageviews', 'DESCENDING'),
|
173 |
+
];
|
174 |
+
} else {
|
175 |
+
$reports_requests[] = [
|
176 |
+
'viewId' => $id_view,
|
177 |
+
'dateRanges' => self::set_date_ranges($daysAgo, 'yesterday'),
|
178 |
+
'metrics' => self::set_metrics([
|
179 |
+
'ga:pageviews',
|
180 |
+
'ga:uniquePageviews',
|
181 |
+
'ga:timeOnPage',
|
182 |
+
'ga:bounces',
|
183 |
+
'ga:entrances',
|
184 |
+
'ga:exits',
|
185 |
+
]),
|
186 |
+
'includeEmptyRows' => true,
|
187 |
+
'pageSize' => 10,
|
188 |
+
'dimensions' => self::set_dimensions('ga:pagePath'),
|
189 |
+
'orderBys' => self::set_order_bys('ga:pageviews', 'DESCENDING'),
|
190 |
+
];
|
191 |
+
}
|
192 |
+
$query = [
|
193 |
+
'reportRequests' => $reports_requests,
|
194 |
+
];
|
195 |
+
|
196 |
+
return $query;
|
197 |
+
}
|
198 |
+
|
199 |
/**
|
200 |
* Preparing query for stats boxes
|
201 |
*
|
258 |
return $query;
|
259 |
}
|
260 |
|
261 |
+
/**
|
262 |
+
* Preparing query for chart
|
263 |
+
*
|
264 |
+
* @param int $id_view The Analytics view ID from which to retrieve data.
|
265 |
+
* @param string $date_range The start date for the query in the format YYYY-MM-DD or '7daysAgo'
|
266 |
+
* @param string $metric A metric expression
|
267 |
+
*
|
268 |
+
* @return array Chart query
|
269 |
+
* @deprecated
|
270 |
+
*
|
271 |
+
*/
|
272 |
+
public static function main_chart_query_old($id_view, $date_range = null, $metric = null)
|
273 |
+
{
|
274 |
+
if (empty($date_range)) {
|
275 |
+
$date_ranges = self::set_date_ranges('7daysAgo', 'yesterday', '14daysAgo', '8daysAgo');
|
276 |
+
} else {
|
277 |
+
$date_ranges = self::set_date_ranges($date_range, 'yesterday', '14daysAgo', '8daysAgo');
|
278 |
+
}
|
279 |
+
|
280 |
+
if (empty($metric)) {
|
281 |
+
$metric = 'ga:pageviews';
|
282 |
+
} else {
|
283 |
+
$metric = 'ga:' . $metric;
|
284 |
+
}
|
285 |
+
|
286 |
+
$reports_requests = [];
|
287 |
+
$reports_requests[] = [
|
288 |
+
'viewId' => $id_view,
|
289 |
+
'dateRanges' => $date_ranges,
|
290 |
+
'metrics' => self::set_metrics($metric),
|
291 |
+
'includeEmptyRows' => true,
|
292 |
+
'dimensions' => self::set_dimensions('ga:date'),
|
293 |
+
];
|
294 |
+
$query = [
|
295 |
+
'reportRequests' => $reports_requests,
|
296 |
+
];
|
297 |
+
|
298 |
+
return $query;
|
299 |
+
}
|
300 |
+
|
301 |
/**
|
302 |
* Preparing query for gender chart
|
303 |
*
|
googleanalytics.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: ShareThis Dashboard for Google Analytics
|
4 |
* Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
|
5 |
* Description: Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
|
6 |
-
* Version: 2.5.
|
7 |
* Author: ShareThis
|
8 |
* Author URI: http://sharethis.com
|
9 |
*/
|
@@ -46,7 +46,7 @@ if ( !preg_match( '/(\/|\\\)' . GA_NAME . '(\/|\\\)/', realpath( __FILE__ ), $te
|
|
46 |
die();
|
47 |
}
|
48 |
|
49 |
-
define( 'GOOGLEANALYTICS_VERSION', '2.5.
|
50 |
include_once GA_PLUGIN_DIR . '/overwrite/ga_overwrite.php';
|
51 |
include_once GA_PLUGIN_DIR . '/class/Ga_Autoloader.php';
|
52 |
include_once GA_PLUGIN_DIR . '/tools/class-support-logging.php';
|
3 |
* Plugin Name: ShareThis Dashboard for Google Analytics
|
4 |
* Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
|
5 |
* Description: Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
|
6 |
+
* Version: 2.5.4
|
7 |
* Author: ShareThis
|
8 |
* Author URI: http://sharethis.com
|
9 |
*/
|
46 |
die();
|
47 |
}
|
48 |
|
49 |
+
define( 'GOOGLEANALYTICS_VERSION', '2.5.4' );
|
50 |
include_once GA_PLUGIN_DIR . '/overwrite/ga_overwrite.php';
|
51 |
include_once GA_PLUGIN_DIR . '/class/Ga_Autoloader.php';
|
52 |
include_once GA_PLUGIN_DIR . '/tools/class-support-logging.php';
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: sharethis, scottstorebloom, scottmweaver
|
3 |
Tags: analytics, google analytics, google analytics plugin, google analytics widget, google analytics dashboard
|
4 |
Requires at least: 5.2
|
5 |
-
Tested up to: 5.8.
|
6 |
-
Stable tag: 2.5.
|
7 |
|
8 |
Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
|
9 |
|
@@ -114,6 +114,10 @@ If you’re using Google Analytics on your WordPress website or a plugin like th
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
|
|
117 |
= 2.5.3
|
118 |
* Fix sending of demographic data once per month.
|
119 |
* Test plugin with WordPress 5.8.1.
|
2 |
Contributors: sharethis, scottstorebloom, scottmweaver
|
3 |
Tags: analytics, google analytics, google analytics plugin, google analytics widget, google analytics dashboard
|
4 |
Requires at least: 5.2
|
5 |
+
Tested up to: 5.8.3
|
6 |
+
Stable tag: 2.5.4
|
7 |
|
8 |
Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
|
9 |
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 2.5.4
|
118 |
+
* Fix dashboard widget.
|
119 |
+
* Test plugin with WordPress 5.8.3.
|
120 |
+
|
121 |
= 2.5.3
|
122 |
* Fix sending of demographic data once per month.
|
123 |
* Test plugin with WordPress 5.8.1.
|