| 1 |
<?php |
| 2 |
$wp_analytify = new WP_Analytify(); |
| 3 |
|
| 4 |
$start_date_val = strtotime("- 30 days"); |
| 5 |
$end_date_val = strtotime("now"); |
| 6 |
$start_date = date( "Y-m-d", $start_date_val); |
| 7 |
$end_date = date( "Y-m-d", $end_date_val); |
| 8 |
|
| 9 |
if( isset( $_POST["view_data"] ) ) { |
| 10 |
|
| 11 |
$s_date = $_POST["st_date"]; |
| 12 |
$ed_date = $_POST["ed_date"]; |
| 13 |
|
| 14 |
} |
| 15 |
|
| 16 |
if( isset( $s_date ) ) { |
| 17 |
$start_date = $s_date; |
| 18 |
} |
| 19 |
|
| 20 |
if( isset( $ed_date ) ) { |
| 21 |
$end_date = $ed_date; |
| 22 |
} |
| 23 |
|
| 24 |
?> |
| 25 |
<div class="wrap"> |
| 26 |
<h2 class='opt-title'><span id='icon-options-general' class='analytics-options'><img src="<?php echo plugins_url('wp-analytify/images/wp-analytics-logo.png');?>" alt=""></span> |
| 27 |
<?php echo __( 'Analytify Dashboard', 'wp-analytify' ); ?> |
| 28 |
</h2> |
| 29 |
<?php |
| 30 |
|
| 31 |
$acces_token = get_option( "post_analytics_token" ); |
| 32 |
if( $acces_token ) { |
| 33 |
|
| 34 |
?> |
| 35 |
<div id="col-container"> |
| 36 |
<div class="metabox-holder"> |
| 37 |
<div class="postbox" style="width:100%;"> |
| 38 |
<div id="main-sortables" class="meta-box-sortables ui-sortable"> |
| 39 |
<div class="postbox "> |
| 40 |
<div class="handlediv" title="Click to toggle"><br /> |
| 41 |
</div> |
| 42 |
<h3 class="hndle"> |
| 43 |
<span> |
| 44 |
<?php |
| 45 |
echo _e('Complete Statistics of the Site ', 'wp-analytify'); |
| 46 |
echo _e(get_option("pt_webprofile_url")); |
| 47 |
echo _e(' Starting From ', 'wp-analytify'); |
| 48 |
echo _e(date("jS F, Y", strtotime($start_date))); |
| 49 |
echo _e(' to ', 'wp-analytify'); |
| 50 |
echo _e(date("jS F, Y", strtotime($end_date))); |
| 51 |
?> |
| 52 |
</span> |
| 53 |
</h3> |
| 54 |
<div class="inside"> |
| 55 |
<div class="pa-filter"> |
| 56 |
<form action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="post"> |
| 57 |
<input type="text" id="st_date" name="st_date" value="<?php echo $start_date; ?>"> |
| 58 |
<input type="text" id="ed_date" name="ed_date" value="<?php echo $end_date; ?>"> |
| 59 |
<input type="submit" id="view_data" name="view_data" value="View Data" class="button-primary btn-green"> |
| 60 |
</form> |
| 61 |
</div> |
| 62 |
|
| 63 |
<a target="_blank" href="http://wp-analytify.com/upgrade-from-free" title="Upgrade to PRO to enjoy full features of Analytify."> |
| 64 |
<img class="gray-areas" src="<?php echo plugins_url('images/live-stats-preview.png', dirname(__FILE__) );?>" width="100%" height="auto" alt="Upgrade to PRO to enjoy full features of Analytify." /> |
| 65 |
</a> |
| 66 |
|
| 67 |
<?php |
| 68 |
|
| 69 |
// General stats // |
| 70 |
|
| 71 |
$stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions,ga:bounces,ga:newUsers,ga:entrances,ga:pageviews,ga:sessionDuration,ga:avgSessionDuration,ga:users', $start_date, $end_date); |
| 72 |
if ( isset( $stats->totalsForAllResults ) ) { |
| 73 |
include ANALYTIFY_ROOT_PATH . '/views/admin/general-stats.php'; |
| 74 |
pa_include_general($wp_analytify,$stats); |
| 75 |
} |
| 76 |
|
| 77 |
// End General stats // |
| 78 |
|
| 79 |
// Top Pages stats // |
| 80 |
$top_page_stats = $wp_analytify->pa_get_analytics_dashboard('ga:pageviews', $start_date, $end_date, 'ga:PageTitle', '-ga:pageviews', false, 5); |
| 81 |
if ( isset( $top_page_stats->totalsForAllResults ) ) { |
| 82 |
include ANALYTIFY_ROOT_PATH . '/views/admin/top-pages-stats.php'; |
| 83 |
pa_include_top_pages_stats( $wp_analytify, $top_page_stats ); |
| 84 |
} |
| 85 |
// End Top Pages stats // |
| 86 |
|
| 87 |
// Country stats // |
| 88 |
|
| 89 |
$country_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:country', '-ga:sessions', false, 5); |
| 90 |
if ( isset( $country_stats->totalsForAllResults )) { |
| 91 |
include ANALYTIFY_ROOT_PATH . '/views/admin/country-stats.php'; |
| 92 |
pa_include_country($wp_analytify,$country_stats); |
| 93 |
} |
| 94 |
|
| 95 |
// End Country stats // |
| 96 |
|
| 97 |
$city_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:city', '-ga:sessions', false, 5); |
| 98 |
if ( isset( $city_stats->totalsForAllResults )) { |
| 99 |
include ANALYTIFY_ROOT_PATH . '/views/admin/city-stats.php'; |
| 100 |
pa_include_city($wp_analytify,$city_stats); |
| 101 |
} |
| 102 |
|
| 103 |
// Keywords stats // |
| 104 |
|
| 105 |
$keyword_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:keyword', '-ga:sessions', false, 10); |
| 106 |
if ( isset( $keyword_stats->totalsForAllResults )){ |
| 107 |
include ANALYTIFY_ROOT_PATH . '/views/admin/keywords-stats.php'; |
| 108 |
pa_include_keywords($wp_analytify,$keyword_stats); |
| 109 |
} |
| 110 |
|
| 111 |
// End Keywords stats // |
| 112 |
|
| 113 |
// Browser stats // |
| 114 |
|
| 115 |
$browser_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:browser,ga:operatingSystem', '-ga:sessions',false,5); |
| 116 |
if ( isset( $browser_stats->totalsForAllResults ) ) { |
| 117 |
include ANALYTIFY_ROOT_PATH . '/views/admin/browser-stats.php'; |
| 118 |
pa_include_browser( $wp_analytify,$browser_stats ); |
| 119 |
} |
| 120 |
|
| 121 |
// End Browser stats // |
| 122 |
|
| 123 |
$operating_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:operatingSystem,ga:operatingSystemVersion', '-ga:sessions', false, 5); |
| 124 |
if ( isset( $city_stats->totalsForAllResults )) { |
| 125 |
include ANALYTIFY_ROOT_PATH . '/views/admin/os-stats.php'; |
| 126 |
pa_include_operating($wp_analytify,$operating_stats); |
| 127 |
} |
| 128 |
|
| 129 |
$mobile_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:mobileDeviceInfo', '-ga:sessions', false, 5); |
| 130 |
if ( isset( $city_stats->totalsForAllResults )) { |
| 131 |
include ANALYTIFY_ROOT_PATH . '/views/admin/mobile-stats.php'; |
| 132 |
pa_include_mobile($wp_analytify,$mobile_stats); |
| 133 |
} |
| 134 |
|
| 135 |
// Referral stats // |
| 136 |
$referr_stats = $wp_analytify->pa_get_analytics_dashboard( 'ga:sessions', $start_date, $end_date, 'ga:source,ga:medium', '-ga:sessions', false, 10); |
| 137 |
if ( isset( $referr_stats->totalsForAllResults ) ) { |
| 138 |
include ANALYTIFY_ROOT_PATH.'/views/admin/referrers-stats.php'; |
| 139 |
pa_include_referrers($wp_analytify,$referr_stats); |
| 140 |
} |
| 141 |
|
| 142 |
// End Referral stats // |
| 143 |
|
| 144 |
|
| 145 |
// Exit stats // |
| 146 |
$page_stats = $wp_analytify->pa_get_analytics_dashboard('ga:entrances,ga:pageviews,ga:exits', $start_date, $end_date, 'ga:PagePath', '-ga:exits', false, 5); |
| 147 |
$top_page_stats = $wp_analytify->pa_get_analytics_dashboard('ga:pageviews', $start_date, $end_date, 'ga:PageTitle', '-ga:pageviews', false, 5); |
| 148 |
if ( isset( $page_stats->totalsForAllResults ) ) { |
| 149 |
include ANALYTIFY_ROOT_PATH . '/views/admin/pages-stats.php'; |
| 150 |
pa_include_pages_stats( $wp_analytify, $page_stats ); |
| 151 |
} |
| 152 |
|
| 153 |
// End Exit stats // |
| 154 |
?> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
<?php |
| 162 |
} |
| 163 |
else{ |
| 164 |
print(_e( 'You must be authenticate to see the Analytics Dashboard.', 'wp-analytify' )); |
| 165 |
} |
| 166 |
|
| 167 |
?> |
| 168 |
</div> |
| 169 |
<script type="text/javascript"> |
| 170 |
|
| 171 |
jQuery(document).ready(function ($) { |
| 172 |
|
| 173 |
$("#st_date").datepicker({ |
| 174 |
dateFormat : 'yy-mm-dd', |
| 175 |
changeMonth : true, |
| 176 |
changeYear : true, |
| 177 |
beforeShow: function() { |
| 178 |
$('#ui-datepicker-div').addClass('mycalander'); |
| 179 |
}, |
| 180 |
yearRange: '-9y:c+nn', |
| 181 |
defaultDate: "<?php echo $start_date;?>" |
| 182 |
}); |
| 183 |
|
| 184 |
$("#ed_date").datepicker({ |
| 185 |
dateFormat : 'yy-mm-dd', |
| 186 |
changeMonth : true, |
| 187 |
changeYear : true, |
| 188 |
beforeShow: function() { |
| 189 |
$('#ui-datepicker-div').addClass('mycalander'); |
| 190 |
}, |
| 191 |
yearRange: '-9y:c+nn', |
| 192 |
defaultDate: "<?php echo $end_date; ?>" |
| 193 |
}); |
| 194 |
}); |
| 195 |
|
| 196 |
jQuery(window).resize(function(){ |
| 197 |
drawChart(); |
| 198 |
drawRegionsMap(); |
| 199 |
}); |
| 200 |
</script> |