Skip to content

Commit

Permalink
fix new vs returning stats
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Feb 18, 2017
1 parent 026bb05 commit 7458897
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion inc/class-wpa-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ public static function load_default_general_stats() {

}

// New vs Returning Users
$new_returning_stats = get_transient( md5( 'show-default-new-returning-dashboard' . $dashboard_profile_ID . $start_date . $end_date ) );
if( $new_returning_stats === false ) {
$new_returning_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:userType' );
set_transient( md5( 'show-default-new-returning-dashboard' . $dashboard_profile_ID . $start_date . $end_date ) , $new_returning_stats, 60 * 60 * 20 );

}

// Device Category Stats
$device_category_stats = get_transient( md5( 'show-default-overall-device-dashboard' . $dashboard_profile_ID . $start_date . $end_date ) );
if ( $device_category_stats === false ) {
Expand All @@ -192,7 +200,7 @@ public static function load_default_general_stats() {
if ( isset( $stats->totalsForAllResults ) ) {

include ANALYTIFY_ROOT_PATH . '/views/default/admin/general-stats.php';
fetch_general_stats( $wp_analytify , $stats , $device_category_stats, $compare_stats , $date_different );
fetch_general_stats( $wp_analytify , $stats , $device_category_stats, $compare_stats , $date_different, $new_returning_stats );
}


Expand Down
7 changes: 4 additions & 3 deletions views/default/admin/general-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
// return array_merge($data, $data1);
// });

function fetch_general_stats( $current, $current_stats, $device_category_stats, $compare_stats , $date_different ) {
function fetch_general_stats( $current, $current_stats, $device_category_stats, $compare_stats , $date_different, $new_returning_stats ) {


$results = $current_stats->totalsForAllResults;

$new_users = $results['ga:newUsers'];
$returning_users = ($results['ga:users'] - $results['ga:newUsers']);
$new_users = $new_returning_stats->rows[0][1];
$returning_users = $new_returning_stats->rows[1][1];

$compare_results = $compare_stats->totalsForAllResults;

Expand Down

0 comments on commit 7458897

Please sign in to comment.