overview.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  1. <?php
  2. /**
  3. * Overview Report
  4. *
  5. * Ensures all of the reports have a uniform class with helper functions.
  6. *
  7. * @since 6.0.0
  8. *
  9. * @package MonsterInsights
  10. * @subpackage Reports
  11. * @author Chris Christoff
  12. */
  13. // Exit if accessed directly
  14. if ( ! defined( 'ABSPATH' ) ) {
  15. exit;
  16. }
  17. final class MonsterInsights_Report_Overview extends MonsterInsights_Report {
  18. public $title;
  19. public $class = 'MonsterInsights_Report_Overview';
  20. public $name = 'overview';
  21. public $version = '1.0.0';
  22. public $level = 'lite';
  23. /**
  24. * Primary class constructor.
  25. *
  26. * @access public
  27. * @since 6.0.0
  28. */
  29. public function __construct() {
  30. $this->title = __( 'Overview', 'google-analytics-for-wordpress' );
  31. parent::__construct();
  32. }
  33. // Outputs the report.
  34. protected function get_report_html( $data = array() ) {
  35. ob_start();
  36. $this->get_overview_top( $data );
  37. if ( ! empty( $data['newvsreturn'] ) && ! empty( $data['devices'] ) ) { ?>
  38. <div class="monsterinsights-reports-2-column-container row">
  39. <div class="monsterinsights-reports-2-column-item col-md-6">
  40. <?php $this->get_newvsreturn( $data ); ?>
  41. </div>
  42. <div class="monsterinsights-reports-2-column-item col-md-6">
  43. <?php $this->get_devices( $data ); ?>
  44. </div>
  45. </div>
  46. <?php
  47. }
  48. if ( ! empty( $data['countries'] ) && ! empty( $data['referrals'] ) ) {
  49. ?>
  50. <div class="monsterinsights-reports-2-column-container row">
  51. <div class="monsterinsights-reports-2-column-item col-md-6 list-has-icons">
  52. <?php $this->get_countries( $data ); ?>
  53. </div>
  54. <div class="monsterinsights-reports-2-column-item col-md-6 list-has-icons">
  55. <?php $this->get_referrals( $data ); ?>
  56. </div>
  57. </div>
  58. <?php
  59. }
  60. $this->get_toppages( $data );
  61. $html = ob_get_clean();
  62. return $html;
  63. }
  64. public function get_overview_report_js( $class = 'sessions', $data ) {
  65. $up = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up.png';
  66. $up2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up@2x.png';
  67. $down = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down.png';
  68. $down2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down@2x.png';
  69. $uplabel = esc_attr__( 'UP', 'google-analytics-for-wordpress' );
  70. $downlabel = esc_attr__( 'DOWN', 'google-analytics-for-wordpress' );
  71. $descriptor = 'sessions' === $class ? esc_js( __( 'Unique', 'google-analytics-for-wordpress' ) ) . '<br />' . esc_js( __( 'Sessions', 'google-analytics-for-wordpress' ) ) : esc_js( __( 'Unique', 'google-analytics-for-wordpress' ) ) . '<br />' . esc_js( __( 'Pageviews', 'google-analytics-for-wordpress' ) );
  72. $descriptor = "'" . $descriptor . "'";
  73. $labels = array();
  74. foreach ( $data['timestamps'] as $timestamp ) {
  75. $labels[] = "'" . esc_js( date_i18n( 'j M', $timestamp ) ) . "'";
  76. }
  77. $datapoints = array();
  78. foreach ( $data[ $class ]['datapoints'] as $datapoint ) {
  79. $datapoints[] = esc_js( $datapoint );
  80. }
  81. $trendpoints = array();
  82. foreach ( $data[ $class ]['trendpoints'] as $trendpoint ) {
  83. $trendpoints[] = esc_js( $trendpoint );
  84. }
  85. ob_start(); ?>
  86. <div class="monsterinsights-reports-box-datagraph" style="position:relative;">
  87. <canvas id="monsterinsights-overview-<?php echo $class; ?>" width="400px" height="400px"></canvas>
  88. <script>
  89. jQuery( document ).ready( function () {
  90. if ( window.uorigindetected != null ) {
  91. Chart.defaults.LineWithLine = Chart.defaults.line;
  92. Chart.controllers.LineWithLine = Chart.controllers.line.extend( {
  93. draw: function ( ease ) {
  94. Chart.controllers.line.prototype.draw.call( this, ease );
  95. if ( this.chart.tooltip._active && this.chart.tooltip._active.length ) {
  96. var activePoint = this.chart.tooltip._active[0],
  97. ctx = this.chart.ctx,
  98. x = activePoint.tooltipPosition().x,
  99. topY = this.chart.scales['y-axis-0'].top,
  100. bottomY = this.chart.scales['y-axis-0'].bottom;
  101. // draw line
  102. ctx.save();
  103. ctx.beginPath();
  104. ctx.moveTo( x, topY );
  105. ctx.lineTo( x, bottomY );
  106. ctx.lineWidth = 1;
  107. ctx.strokeStyle = '#6db0e9';
  108. ctx.setLineDash( [10, 10] );
  109. ctx.stroke();
  110. ctx.restore();
  111. }
  112. }
  113. } );
  114. var ctx = document.getElementById( "monsterinsights-overview-<?php echo $class;?>" );
  115. var data = {
  116. labels: [<?php echo implode( ', ', $labels ); ?>],
  117. datasets: [
  118. {
  119. lineTension: 0, // ChartJS doesn't make nice curves like in the PSD so for now leaving straight on
  120. borderColor: '#5fa6e7',
  121. backgroundColor: 'rgba( 109, 176, 233, 0.2)',
  122. fillOpacity: 0.2,
  123. fillColor: 'rgba( 109, 176, 233, 0.2)',
  124. pointRadius: 4,
  125. pointBorderColor: '#3783c4',
  126. pointBackgroundColor: '#FFF',
  127. hoverRadius: 1,
  128. pointHoverBackgroundColor: '#FFF',// Point background color when hovered.
  129. pointHoverBorderColor: '#3783c4',//Point border color when hovered.
  130. pointHoverBorderWidth: 4,//Border width of point when hovered.
  131. pointHoverRadius: 6,//The radius of the point when hovered.
  132. labels: [<?php echo implode( ', ', $labels ); ?>],
  133. data: [<?php echo implode( ', ', $datapoints ); ?>],
  134. trend: [<?php echo implode( ', ', $trendpoints ); ?>],
  135. },
  136. ]
  137. };
  138. var overviewTooltips = function ( tooltip ) {
  139. // Tooltip Element
  140. var tooltipEl = jQuery( '#monsterinsights-chartjs-tooltip' );
  141. if ( ! tooltipEl[0] ) {
  142. jQuery( 'body' ).append( '<div id="monsterinsights-chartjs-tooltip" style="padding:10px;"></div>' );
  143. tooltipEl = jQuery( '#monsterinsights-chartjs-tooltip' );
  144. }
  145. // Hide if no tooltip
  146. if ( ! tooltip.opacity ) {
  147. tooltipEl.css( {
  148. opacity: 0
  149. } );
  150. jQuery( '.chartjs-wrap canvas' ).each( function ( index, el ) {
  151. jQuery( el ).css( 'cursor', 'default' );
  152. } );
  153. return;
  154. }
  155. jQuery( this._chart.canvas ).css( 'cursor', 'pointer' );
  156. // Set caret Position
  157. tooltipEl.removeClass( 'above below no-transform' );
  158. if ( tooltip.yAlign ) {
  159. tooltipEl.addClass( tooltip.yAlign );
  160. } else {
  161. tooltipEl.addClass( 'no-transform' );
  162. }
  163. var label = tooltip.title[0];
  164. var value = tooltip.title[1];
  165. var change = tooltip.title[2];
  166. var trend = '';
  167. if ( change == 0 ) {
  168. trend += '0%';
  169. } else if ( change > 0 ) {
  170. trend += '<img src="<?php echo esc_url( $up ); ?>"';
  171. trend += 'srcset="<?php echo esc_url( $up2x ); ?> 2x"';
  172. trend += 'alt="<?php echo esc_attr( $uplabel ); ?>" style="margin-right:6px"/>' + change + '%';
  173. } else {
  174. trend += '<img src="<?php echo esc_url( $down ); ?>"';
  175. trend += 'srcset="<?php echo esc_url( $down2x ); ?> 2x"';
  176. trend += 'alt="<?php echo esc_attr( $downlabel ); ?>" style="margin-right:6px"/>' + Math.abs( change ) + '%';
  177. }
  178. var html = '<div class="monsterinsights-reports-overview-datagraph-tooltip-container">';
  179. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-title">' + label + '</div>';
  180. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-number">' + value + '</div>';
  181. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-descriptor">' + <?php echo wp_kses_post( $descriptor ); ?> + '</div>';
  182. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-trend">' + trend + '</div>';
  183. html += '</div>';
  184. tooltipEl.html( html );
  185. // Find Y Location on page
  186. var top = 0;
  187. if ( tooltip.yAlign ) {
  188. var ch = 0;
  189. if ( tooltip.caretHeight ) {
  190. ch = tooltip.caretHeight;
  191. }
  192. if ( tooltip.yAlign == 'above' ) {
  193. top = tooltip.y - ch - tooltip.caretPadding;
  194. } else {
  195. top = tooltip.y + ch + tooltip.caretPadding;
  196. }
  197. }
  198. // Display, position, and set styles for font
  199. tooltipEl.css( {
  200. opacity: 1,
  201. width: tooltip.width ? (
  202. tooltip.width + 'px'
  203. ) : 'auto',
  204. left: tooltip.x - 50 + 'px',
  205. top: top + 68 + 'px',
  206. fontFamily: tooltip._fontFamily,
  207. fontSize: tooltip.fontSize,
  208. fontStyle: tooltip._fontStyle,
  209. padding: tooltip.yPadding + 'px ' + tooltip.xPadding + 'px',
  210. 'z-index': 99999,
  211. } );
  212. };
  213. var MonsterInsightsOverview<?php echo time();?> = new Chart( ctx, {
  214. type: 'LineWithLine',
  215. data: data,
  216. plugins: [
  217. {
  218. afterRender: function () {
  219. var parent = jQuery( '.monsterinsights-overview-report-overview-graph-panel .monsterinsights-tabbed-nav-tab-title[data-tab=\'pageviews-tab\']' ).hasClass( 'active' );
  220. if ( ! parent && '<?php echo $class; ?>' == 'pageviews' ) {
  221. jQuery( '.monsterinsights-tabbed-nav-panel.pageviews-tab' ).hide();
  222. }
  223. },
  224. }
  225. ],
  226. options: {
  227. legend: {
  228. display: false,
  229. },
  230. hover: {
  231. intersect: true,
  232. },
  233. tooltips: {
  234. enabled: false,
  235. yAlign: 'top',
  236. xAlign: 'top',
  237. intersect: false,
  238. custom: overviewTooltips,
  239. callbacks: {
  240. title: function ( tooltipItem, data ) {
  241. tooltipItem = tooltipItem[0];
  242. var label = data.datasets[0].labels[tooltipItem.index];
  243. var value = data.datasets[0].data[tooltipItem.index];
  244. var change = data.datasets[0].trend[tooltipItem.index];
  245. return [label, value, change];
  246. },
  247. label: function ( tooltipItem, data ) {
  248. return '';
  249. }
  250. }
  251. },
  252. scales: {
  253. xAxes: [
  254. {
  255. spanGaps: true,
  256. position: 'bottom',
  257. gridLines: {
  258. show: true,
  259. color: '#f2f6fa',
  260. },
  261. ticks: {
  262. fontColor: '#7f8591',
  263. }
  264. }
  265. ],
  266. yAxes: [
  267. {
  268. gridLines: {
  269. show: true,
  270. color: '#d4e2ef',
  271. },
  272. ticks: {
  273. fontColor: '#7f8591',
  274. callback: function ( value ) {
  275. if ( value % 1 === 0 ) {
  276. return value;
  277. }
  278. }
  279. }
  280. }
  281. ]
  282. },
  283. animation: false,
  284. legend: {
  285. display: false,
  286. },
  287. responsive: true,
  288. maintainAspectRatio: false,
  289. borderWidth: 1,
  290. }
  291. } );
  292. }
  293. } );
  294. </script>
  295. </div>
  296. <?php
  297. $html = ob_get_clean();
  298. return $html;
  299. }
  300. /**
  301. * Merge the 2 top reports into one for easier grabbing in the dashboard widget.
  302. *
  303. * @param array $data The data from GA.
  304. */
  305. public function get_overview_top( $data ) {
  306. $this->get_overviewgraph( $data );
  307. $this->get_infobox( $data );
  308. }
  309. public function get_overviewgraph( $data ) {
  310. if ( ! empty( $data['overviewgraph']['count'] ) && $data['overviewgraph']['count'] > 0 ) {
  311. ?>
  312. <div class="monsterinsights-overview-report-overview-graph-panel panel panel-default chart-panel">
  313. <ul class="monsterinsights-tabbed-nav nav nav-tabs nav-justified">
  314. <li role="presentation" class="monsterinsights-tabbed-nav-tab-title monsterinsights-clear active" data-tab="sessions-tab">
  315. <a href="#sessions-tab"><span class="monsterinsights-user-icon"></span>
  316. <?php echo esc_html__( 'Sessions', 'google-analytics-for-wordpress' ); ?>
  317. </a>
  318. </li>
  319. <li role="presentation" class="monsterinsights-tabbed-nav-tab-title monsterinsights-clear" data-tab="pageviews-tab">
  320. <a href="#pageviews-tab"><span class="monsterinsights-eye-icon"> </span>
  321. <?php echo esc_html__( 'Pageviews', 'google-analytics-for-wordpress' ); ?>
  322. </a>
  323. </ul>
  324. <div class="monsterinsights-tabbed-nav-panel sessions-tab">
  325. <div class="panel-body">
  326. <?php echo $this->get_overview_report_js( 'sessions', $data['overviewgraph'] ); ?>
  327. </div>
  328. </div>
  329. <div class="monsterinsights-tabbed-nav-panel pageviews-tab">
  330. <div class="panel-body">
  331. <?php echo $this->get_overview_report_js( 'pageviews', $data['overviewgraph'] ); ?>
  332. </div>
  333. </div>
  334. <div id="monsterinsights-chartjs-tooltip" style="opacity: 0"></div>
  335. </div>
  336. <?php }
  337. }
  338. public function get_infobox( $data ) {
  339. if ( ! empty( $data['infobox'] ) ) {
  340. $up = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up.png';
  341. $up2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up@2x.png';
  342. $down = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down.png';
  343. $down2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down@2x.png';
  344. $upred = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up-red.png';
  345. $upred2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/up-red@2x.png';
  346. $downgrn = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down-green.png';
  347. $downgrn2x = MONSTERINSIGHTS_PLUGIN_URL . 'assets/images/down-green@2x.png';
  348. $uplabel = esc_attr__( 'Up', 'google-analytics-for-wordpress' );
  349. $downlabel = esc_attr__( 'Down', 'google-analytics-for-wordpress' );
  350. ?>
  351. <div class="monsterinsights-overview-report-infobox-panel panel row container-fluid">
  352. <div class="monsterinsights-reports-infobox col-md-3 col-xs-6">
  353. <div class="monsterinsights-reports-infobox-title">
  354. <?php echo esc_html__( 'Sessions', 'google-analytics-for-wordpress' ); ?>
  355. </div>
  356. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Session', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'A session is the browsing session of a single user to your site.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  357. <div class="monsterinsights-reports-infobox-number" title="<?php echo esc_attr( number_format_i18n( $data['infobox']['sessions']['value'] ) ); ?>">
  358. <?php echo esc_html( monsterinsights_round_number( $data['infobox']['sessions']['value'] ) ); ?>
  359. </div>
  360. <?php if ( empty( $data['infobox']['sessions']['prev'] ) ) { ?>
  361. <div class="monsterinsights-reports-infobox-prev">
  362. <?php echo esc_html__( 'No change', 'google-analytics-for-wordpress' ); ?>
  363. </div>
  364. <?php } else if ( $data['infobox']['sessions']['prev'] > 0 ) { ?>
  365. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-up">
  366. <img src="<?php echo $up; ?>" srcset="<?php echo $up2x; ?> 2x" alt="<?php echo $uplabel; ?>"/>
  367. <?php echo esc_html( $data['infobox']['sessions']['prev'] ) . '%'; ?>
  368. </div>
  369. <?php } else { ?>
  370. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-down">
  371. <img src="<?php echo $down; ?>" srcset="<?php echo $down2x; ?> 2x" alt="<?php echo $downlabel; ?>"/>
  372. <?php echo esc_html( absint( $data['infobox']['sessions']['prev'] ) ) . '%'; ?>
  373. </div>
  374. <?php } ?>
  375. <div class="monsterinsights-reports-infobox-compare">
  376. <?php echo sprintf( esc_html__( 'vs. Previous %s Days', 'google-analytics-for-wordpress' ), $data['infobox']['range'] ); ?>
  377. </div>
  378. </div>
  379. <div class="monsterinsights-reports-infobox col-md-3 col-xs-6">
  380. <div class="monsterinsights-reports-infobox-title">
  381. <?php echo esc_html__( 'Pageviews', 'google-analytics-for-wordpress' ); ?>
  382. </div>
  383. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Pageviews', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'A pageview is defined as a view of a page on your site that is being tracked by the Analytics tracking code. Each refresh of a page is also a new pageview.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  384. <div class="monsterinsights-reports-infobox-number" title="<?php echo esc_attr( number_format_i18n( $data['infobox']['pageviews']['value'] ) ); ?>">
  385. <?php echo esc_html( monsterinsights_round_number( $data['infobox']['pageviews']['value'] ) ); ?>
  386. </div>
  387. <?php if ( empty( $data['infobox']['pageviews']['prev'] ) ) { ?>
  388. <div class="monsterinsights-reports-infobox-prev">
  389. <?php echo esc_html__( 'No change', 'google-analytics-for-wordpress' ); ?>
  390. </div>
  391. <?php } else if ( $data['infobox']['pageviews']['prev'] > 0 ) { ?>
  392. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-up">
  393. <img src="<?php echo $up; ?>" srcset="<?php echo $up2x; ?> 2x" alt="<?php echo $uplabel; ?>"/>
  394. <?php echo esc_html( $data['infobox']['pageviews']['prev'] ) . '%'; ?>
  395. </div>
  396. <?php } else { ?>
  397. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-down">
  398. <img src="<?php echo $down; ?>" srcset="<?php echo $down2x; ?> 2x" alt="<?php echo $downlabel; ?>"/>
  399. <?php echo esc_html( absint( $data['infobox']['pageviews']['prev'] ) ) . '%'; ?>
  400. </div>
  401. <?php } ?>
  402. <div class="monsterinsights-reports-infobox-compare">
  403. <?php echo sprintf( esc_html__( 'vs. Previous %s Days', 'google-analytics-for-wordpress' ), $data['infobox']['range'] ); ?>
  404. </div>
  405. </div>
  406. <div class="monsterinsights-reports-infobox col-md-3 col-xs-6">
  407. <div class="monsterinsights-reports-infobox-title">
  408. <?php echo esc_html__( 'Avg. Session Duration', 'google-analytics-for-wordpress' ); ?>
  409. </div>
  410. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Average Session Duration', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'Total duration of all sessions (in seconds) / number of sessions.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  411. <div class="monsterinsights-reports-infobox-number">
  412. <?php echo esc_html( $data['infobox']['duration']['value'] ); ?>
  413. </div>
  414. <?php if ( empty( $data['infobox']['duration']['prev'] ) ) { ?>
  415. <div class="monsterinsights-reports-infobox-prev">
  416. <?php echo esc_html__( 'No change', 'google-analytics-for-wordpress' ); ?>
  417. </div>
  418. <?php } else if ( $data['infobox']['duration']['prev'] > 0 ) { ?>
  419. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-up">
  420. <img src="<?php echo $up; ?>" srcset="<?php echo $up2x; ?> 2x" alt="<?php echo $uplabel; ?>"/>
  421. <?php echo esc_html( $data['infobox']['duration']['prev'] ) . '%'; ?>
  422. </div>
  423. <?php } else { ?>
  424. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-down">
  425. <img src="<?php echo $down; ?>" srcset="<?php echo $down2x; ?> 2x" alt="<?php echo $downlabel; ?>"/>
  426. <?php echo esc_html( absint( $data['infobox']['duration']['prev'] ) ) . '%'; ?>
  427. </div>
  428. <?php } ?>
  429. <div class="monsterinsights-reports-infobox-compare">
  430. <?php echo sprintf( esc_html__( 'vs. Previous %s Days', 'google-analytics-for-wordpress' ), $data['infobox']['range'] ); ?>
  431. </div>
  432. </div>
  433. <div class="monsterinsights-reports-infobox col-md-3 col-xs-6">
  434. <div class="monsterinsights-reports-infobox-title">
  435. <?php echo esc_html__( 'Bounce Rate', 'google-analytics-for-wordpress' ); ?>
  436. </div>
  437. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Bounce Rate', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'Percentage of single page visits (or web sessions). It is the number of visits in which a person leaves your website from the landing page without browsing any further.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  438. <div class="monsterinsights-reports-infobox-number">
  439. <?php echo esc_html( $data['infobox']['bounce']['value'] ) . '%'; ?>
  440. </div>
  441. <?php if ( empty( $data['infobox']['bounce']['prev'] ) ) { ?>
  442. <div class="monsterinsights-reports-infobox-prev">
  443. <?php echo esc_html__( 'No change', 'google-analytics-for-wordpress' ); ?>
  444. </div>
  445. <?php } else if ( $data['infobox']['bounce']['prev'] > 0 ) { ?>
  446. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-up monsterinsights-reports-infobox-red">
  447. <img src="<?php echo $upred; ?>" srcset="<?php echo $upred2x; ?> 2x" alt="<?php echo $uplabel; ?>"/>
  448. <?php echo esc_html( $data['infobox']['bounce']['prev'] ) . '%'; ?>
  449. </div>
  450. <?php } else { ?>
  451. <div class="monsterinsights-reports-infobox-prev monsterinsights-reports-infobox-down monsterinsights-reports-infobox-green">
  452. <img src="<?php echo $downgrn; ?>" srcset="<?php echo $downgrn2x; ?> 2x" alt="<?php echo $downlabel; ?>"/>
  453. <?php echo esc_html( absint( $data['infobox']['bounce']['prev'] ) ) . '%'; ?>
  454. </div>
  455. <?php } ?>
  456. <div class="monsterinsights-reports-infobox-compare">
  457. <?php echo sprintf( esc_html__( 'vs. Previous %s Days', 'google-analytics-for-wordpress' ), $data['infobox']['range'] ); ?>
  458. </div>
  459. </div>
  460. </div>
  461. <?php }
  462. }
  463. public function get_newvsreturn( $data ) {
  464. if ( ! empty( $data['newvsreturn'] ) ) {
  465. ?>
  466. <div class="monsterinsights-reports-2-column-panel panel monsterinsights-pie-chart-panel chart-panel">
  467. <div class="monsterinsights-reports-panel-title">
  468. <?php echo esc_html__( 'New vs. Returning Visitors', 'google-analytics-for-wordpress' ); ?>
  469. </div>
  470. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'New vs. Returning Visitors', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'This graph shows what percent of your user sessions come from new versus repeat visitors.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  471. <div class="monsterinsights-reports-pie-graph monsterinsights-clear">
  472. <div id="monsterinsights-chartjs-pie-returning-tooltip" style="opacity: 0"></div>
  473. <canvas id="monsterinsights-reports-returning-visitor-chart" width="200px" height="200px" style="max-width:200px;max-height:200px"></canvas>
  474. <script type="text/javascript">
  475. jQuery( document ).ready( function () {
  476. if ( window.uorigindetected != null ) {
  477. var pieTooltips = function ( tooltip ) {
  478. // Tooltip Element
  479. var tooltipEl = jQuery( '#monsterinsights-chartjs-pie-returning-tooltip' );
  480. if ( ! tooltipEl[0] ) {
  481. jQuery( 'body' ).append( '<div id="monsterinsights-chartjs-pie-returning-tooltip" style="padding:10px;"></div>' );
  482. tooltipEl = jQuery( '#monsterinsights-chartjs-pie-returning-tooltip' );
  483. }
  484. // Hide if no tooltip
  485. if ( ! tooltip.opacity ) {
  486. tooltipEl.css( {
  487. opacity: 0
  488. } );
  489. jQuery( '.chartjs-wrap canvas' ).each( function ( index, el ) {
  490. jQuery( el ).css( 'cursor', 'default' );
  491. } );
  492. return;
  493. }
  494. jQuery( this._chart.canvas ).css( 'cursor', 'pointer' );
  495. // Set caret Position
  496. tooltipEl.removeClass( 'above below no-transform' );
  497. if ( tooltip.yAlign ) {
  498. tooltipEl.addClass( tooltip.yAlign );
  499. } else {
  500. tooltipEl.addClass( 'no-transform' );
  501. }
  502. var label = tooltip.title[0];
  503. var value = tooltip.title[1];
  504. var html = '<div class="monsterinsights-reports-overview-datagraph-tooltip-container">';
  505. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-title">' + label + '</div>';
  506. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-number">' + value + '%</div>';
  507. html += '</div>';
  508. tooltipEl.html( html );
  509. // Find Y Location on page
  510. var top = 0;
  511. if ( tooltip.yAlign ) {
  512. var ch = 0;
  513. if ( tooltip.caretHeight ) {
  514. ch = tooltip.caretHeight;
  515. }
  516. if ( tooltip.yAlign == 'above' ) {
  517. top = tooltip.y - ch - tooltip.caretPadding;
  518. } else {
  519. top = tooltip.y + ch + tooltip.caretPadding;
  520. }
  521. }
  522. // Display, position, and set styles for font
  523. tooltipEl.css( {
  524. opacity: 1,
  525. width: tooltip.width ? (
  526. tooltip.width + 'px'
  527. ) : 'auto',
  528. left: tooltip.x - 50 + 'px',
  529. top: top - 40 + 'px',
  530. fontFamily: tooltip._fontFamily,
  531. fontSize: tooltip.fontSize,
  532. fontStyle: tooltip._fontStyle,
  533. padding: tooltip.yPadding + 'px ' + tooltip.xPadding + 'px',
  534. 'z-index': 99999,
  535. } );
  536. };
  537. var config = {
  538. type: 'doughnut',
  539. data: {
  540. datasets: [
  541. {
  542. data: [
  543. <?php echo esc_js( $data['newvsreturn']['new'] ); ?>,
  544. <?php echo esc_js( $data['newvsreturn']['returning'] ); ?>,
  545. ],
  546. backgroundColor: [
  547. '#2077c4',
  548. '#52a7f4'
  549. ],
  550. }
  551. ],
  552. values: [<?php echo esc_js( $data['newvsreturn']['new'] ); ?>,<?php echo esc_js( $data['newvsreturn']['returning'] ); ?> ],
  553. labels: [
  554. "<?php echo esc_js( __( 'New', 'google-analytics-for-wordpress' ) ); ?>",
  555. "<?php echo esc_js( __( 'Returning', 'google-analytics-for-wordpress' ) ); ?>",
  556. ]
  557. },
  558. options: {
  559. responsive: true,
  560. maintainAspectRatio: false,
  561. tooltips: {
  562. enabled: false,
  563. yAlign: 'top',
  564. xAlign: 'top',
  565. intersect: true,
  566. custom: pieTooltips,
  567. callbacks: {
  568. title: function ( tooltipItem, data ) {
  569. tooltipItem = tooltipItem[0];
  570. var label = data.labels[tooltipItem.index];
  571. var value = data.datasets[0].data[tooltipItem.index];
  572. return [label, value];
  573. },
  574. label: function ( tooltipItem, data ) {
  575. return '';
  576. }
  577. }
  578. },
  579. animation: false,
  580. legendCallback: function ( chart ) {
  581. var text = [];
  582. text.push( '<ul class="' + chart.id + '-legend" style="list-style:none">' );
  583. for ( var i = 0; i < chart.data.datasets[0].data.length; i ++ ) {
  584. text.push( '<li style="color: #23282d;font-size: 16px;font-weight: 400;"><div style="color: #23282d;width:12px;height:12px;display:inline-block;background:' + chart.data.datasets[0].backgroundColor[i] + '" />&nbsp;' );
  585. if ( typeof(
  586. chart
  587. ) != 'undefined' && typeof(
  588. chart.data
  589. ) != 'undefined' && typeof(
  590. chart.data.labels
  591. ) != 'undefined' && typeof(
  592. chart.data.labels[i]
  593. ) != 'undefined' ) {
  594. text.push( chart.data.labels[i] );
  595. }
  596. if ( typeof(
  597. chart
  598. ) != 'undefined' && typeof(
  599. chart.data
  600. ) != 'undefined' && typeof(
  601. chart.data.values
  602. ) != 'undefined' && typeof(
  603. chart.data.values[i]
  604. ) != 'undefined' ) {
  605. text.push( '<span class="monsterinsights-pie-chart-legend-number">' + chart.data.values[i] + '%</span>' );
  606. }
  607. text.push( '</li>' );
  608. }
  609. text.push( '</ul>' );
  610. return text.join( '' );
  611. },
  612. legend: {display: false},
  613. }
  614. };
  615. var overviewreturning = new Chart( document.getElementById( 'monsterinsights-reports-returning-visitor-chart' ).getContext( '2d' ), config );
  616. jQuery( '.monsterinsights-reports-pie-graph-key' ).html( overviewreturning.generateLegend() );
  617. }
  618. } );
  619. </script>
  620. </div>
  621. <div class="monsterinsights-reports-pie-graph-key"></div>
  622. </div>
  623. <?php
  624. }
  625. }
  626. public function get_devices( $data ) {
  627. if ( ! empty( $data['devices'] ) ) {
  628. ?>
  629. <div class="monsterinsights-reports-2-column-panel panel monsterinsights-pie-chart-panel chart-panel">
  630. <div class="monsterinsights-reports-panel-title">
  631. <?php echo esc_html__( 'Device Breakdown', 'google-analytics-for-wordpress' ); ?>
  632. </div>
  633. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Device Breakdown', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'This graph shows what percent of your visitor sessions are done using a traditional computer or laptop, tablet or mobile device to view your site.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  634. <div class="monsterinsights-reports-pie-graph monsterinsights-clear">
  635. <div id="monsterinsights-chartjs-pie-devices-tooltip" style="opacity: 0"></div>
  636. <canvas id="monsterinsights-reports-devices-chart" width="200px" height="200px" style="max-width:200px;max-height:200px"></canvas>
  637. <script type="text/javascript">
  638. jQuery( document ).ready( function () {
  639. if ( window.uorigindetected != null ) {
  640. var pieTooltips = function ( tooltip ) {
  641. // Tooltip Element
  642. var tooltipEl = jQuery( '#monsterinsights-chartjs-pie-devices-tooltip' );
  643. if ( ! tooltipEl[0] ) {
  644. jQuery( 'body' ).append( '<div id="monsterinsights-chartjs-pie-devices-tooltip" style="padding:10px;"></div>' );
  645. tooltipEl = jQuery( '#monsterinsights-chartjs-pie-devices-tooltip' );
  646. }
  647. // Hide if no tooltip
  648. if ( ! tooltip.opacity ) {
  649. tooltipEl.css( {
  650. opacity: 0
  651. } );
  652. jQuery( '.chartjs-wrap canvas' ).each( function ( index, el ) {
  653. jQuery( el ).css( 'cursor', 'default' );
  654. } );
  655. return;
  656. }
  657. jQuery( this._chart.canvas ).css( 'cursor', 'pointer' );
  658. // Set caret Position
  659. tooltipEl.removeClass( 'above below no-transform' );
  660. if ( tooltip.yAlign ) {
  661. tooltipEl.addClass( tooltip.yAlign );
  662. } else {
  663. tooltipEl.addClass( 'no-transform' );
  664. }
  665. var label = tooltip.title[0];
  666. var value = tooltip.title[1];
  667. var html = '<div class="monsterinsights-reports-overview-datagraph-tooltip-container">';
  668. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-title">' + label + '</div>';
  669. html += '<div class="monsterinsights-reports-overview-datagraph-tooltip-number">' + value + '%</div>';
  670. html += '</div>';
  671. tooltipEl.html( html );
  672. // Find Y Location on page
  673. var top = 0;
  674. if ( tooltip.yAlign ) {
  675. var ch = 0;
  676. if ( tooltip.caretHeight ) {
  677. ch = tooltip.caretHeight;
  678. }
  679. if ( tooltip.yAlign == 'above' ) {
  680. top = tooltip.y - ch - tooltip.caretPadding;
  681. } else {
  682. top = tooltip.y + ch + tooltip.caretPadding;
  683. }
  684. }
  685. // Display, position, and set styles for font
  686. tooltipEl.css( {
  687. opacity: 1,
  688. width: tooltip.width ? (
  689. tooltip.width + 'px'
  690. ) : 'auto',
  691. left: tooltip.x - 50 + 'px',
  692. top: top - 40 + 'px',
  693. fontFamily: tooltip._fontFamily,
  694. fontSize: tooltip.fontSize,
  695. fontStyle: tooltip._fontStyle,
  696. padding: tooltip.yPadding + 'px ' + tooltip.xPadding + 'px',
  697. 'z-index': 99999,
  698. } );
  699. };
  700. var config = {
  701. type: 'doughnut',
  702. data: {
  703. datasets: [
  704. {
  705. data: [
  706. <?php echo esc_js( $data['devices']['desktop'] ); ?>,
  707. <?php echo esc_js( $data['devices']['tablet'] ); ?>,
  708. <?php echo esc_js( $data['devices']['mobile'] ); ?>,
  709. ],
  710. backgroundColor: [
  711. '#2077c4',
  712. '#52a7f4',
  713. '#afd9ff'
  714. ],
  715. }
  716. ],
  717. values: [<?php echo esc_js( $data['devices']['desktop'] ); ?>,<?php echo esc_js( $data['devices']['tablet'] ); ?>,<?php echo esc_js( $data['devices']['mobile'] ); ?> ],
  718. labels: [
  719. "<?php echo esc_js( __( 'Desktop', 'google-analytics-for-wordpress' ) ); ?>",
  720. "<?php echo esc_js( __( 'Tablet', 'google-analytics-for-wordpress' ) ); ?>",
  721. "<?php echo esc_js( __( 'Mobile', 'google-analytics-for-wordpress' ) ); ?>",
  722. ]
  723. },
  724. options: {
  725. responsive: true,
  726. maintainAspectRatio: false,
  727. tooltips: {
  728. enabled: false,
  729. yAlign: 'top',
  730. xAlign: 'top',
  731. intersect: true,
  732. custom: pieTooltips,
  733. callbacks: {
  734. title: function ( tooltipItem, data ) {
  735. tooltipItem = tooltipItem[0];
  736. var label = data.labels[tooltipItem.index];
  737. var value = data.datasets[0].data[tooltipItem.index];
  738. return [label, value];
  739. },
  740. label: function ( tooltipItem, data ) {
  741. return '';
  742. }
  743. }
  744. },
  745. animation: false,
  746. legendCallback: function ( chart ) {
  747. var text = [];
  748. text.push( '<ul class="' + chart.id + '-legend" style="list-style:none">' );
  749. for ( var i = 0; i < chart.data.datasets[0].data.length; i ++ ) {
  750. text.push( '<li style="color: #23282d;font-size: 16px;font-weight: 400;"><div style="color: #23282d;width:12px;height:12px;display:inline-block;background:' + chart.data.datasets[0].backgroundColor[i] + '" />&nbsp;' );
  751. if ( typeof(
  752. chart
  753. ) != 'undefined' && typeof(
  754. chart.data
  755. ) != 'undefined' && typeof(
  756. chart.data.labels
  757. ) != 'undefined' && typeof(
  758. chart.data.labels[i]
  759. ) != 'undefined' ) {
  760. text.push( chart.data.labels[i] );
  761. }
  762. if ( typeof(
  763. chart
  764. ) != 'undefined' && typeof(
  765. chart.data
  766. ) != 'undefined' && typeof(
  767. chart.data.values
  768. ) != 'undefined' && typeof(
  769. chart.data.values[i]
  770. ) != 'undefined' ) {
  771. text.push( '<span class="monsterinsights-pie-chart-legend-number">' + chart.data.values[i] + '%</span>' );
  772. }
  773. text.push( '</li>' );
  774. }
  775. text.push( '</ul>' );
  776. return text.join( '' );
  777. },
  778. legend: {display: false},
  779. }
  780. };
  781. var devicebreakdown = new Chart( document.getElementById( 'monsterinsights-reports-devices-chart' ).getContext( '2d' ), config );
  782. jQuery( '.monsterinsights-reports-pie-visitors-graph-key' ).html( devicebreakdown.generateLegend() );
  783. }
  784. } );
  785. </script>
  786. </div>
  787. <div class="monsterinsights-reports-pie-visitors-graph-key"></div>
  788. </div>
  789. <?php
  790. }
  791. }
  792. public function get_countries( $data ) {
  793. if ( ! empty( $data['newvsreturn'] ) ) {
  794. ?>
  795. <div class="monsterinsights-reports-2-column-panel panel nopadding">
  796. <div class="monsterinsights-reports-panel-title">
  797. <?php echo esc_html__( 'Top 10 Countries', 'google-analytics-for-wordpress' ); ?>
  798. </div>
  799. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Top 10 Countries', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'This list shows the top countries your website visitors are from.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  800. <div class="monsterinsights-reports-list">
  801. <ul class="monsterinsights-reports-country-list list-group">
  802. <?php
  803. $countries = monsterinsights_get_country_list( true );
  804. $i = 1;
  805. foreach ( $data['countries'] as $icountry => $countrydata ) {
  806. if ( ! empty( $countries[ $countrydata['iso'] ] ) ) {
  807. echo '<li class="list-group-item"><span class="monsterinsights-reports-list-count">' . $i . '.</span><span class="monsterinsights-reports-country-flag monsterinsights-flag-icon monsterinsights-flag-icon-' . strtolower( $countrydata['iso'] ) . ' "></span><span class="monsterinsights-reports-list-text">' . $countries[ $countrydata['iso'] ] . '</span><span class="monsterinsights-reports-list-number">' . number_format_i18n( $countrydata['sessions'] ) . '</span></li>';
  808. } else {
  809. echo '<li class="list-group-item"><span class="monsterinsights-reports-list-count">' . $i . '</span><span class="monsterinsights-flag-icon monsterinsights-flag-icon-' . strtolower( $countrydata['iso'] ) . ' "></span><span class="monsterinsights-reports-list-text">' . $countrydata['iso'] . '</span><span class="monsterinsights-reports-list-number">' . number_format_i18n( $countrydata['sessions'] ) . '</span></li>';
  810. }
  811. $i ++;
  812. }
  813. ?>
  814. </ul>
  815. </div>
  816. <?php
  817. $referral_url = 'https://analytics.google.com/analytics/web/#report/visitors-geo/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data );
  818. ?>
  819. <div class="monsterinsights-reports-panel-footer">
  820. <a href="<?php echo $referral_url; ?>" target="_blank" title="<?php echo esc_html__( 'View Full Countries Report', 'google-analytics-for-wordpress' ); ?>" class="monsterinsights-reports-panel-footer-button"><?php echo esc_html__( 'View All Countries Report', 'google-analytics-for-wordpress' ); ?></a>
  821. </div>
  822. </div>
  823. <?php
  824. }
  825. }
  826. public function get_referrals( $data ) {
  827. if ( ! empty( $data['referrals'] ) ) {
  828. ?>
  829. <div class="monsterinsights-reports-2-column-panel panel nopadding">
  830. <div class="monsterinsights-reports-panel-title">
  831. <?php echo esc_html__( 'Referrals', 'google-analytics-for-wordpress' ); ?>
  832. </div>
  833. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Referrals', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'This list shows the top websites that send your website traffic, known as "referral traffic".', 'google-analytics-for-wordpress' ) ); ?>"></div>
  834. <div class="monsterinsights-reports-list">
  835. <ul class="monsterinsights-reports-referral-list list-group">
  836. <?php
  837. $i = 1;
  838. foreach ( $data['referrals'] as $ireferrals => $referralsdata ) {
  839. echo '<li class="list-group-item">' .
  840. '<span class="monsterinsights-reports-list-count">'
  841. . $i .
  842. '</span>' .
  843. '<img class="monsterinsights-reports-referral-icon" src="https://www.google.com/s2/favicons?domain=' . $referralsdata['url'] . '" width="16px" height="16px" />' .
  844. '<span class="monsterinsights-reports-list-text">'
  845. . $referralsdata['url'] .
  846. '</span>
  847. <span class="monsterinsights-reports-list-number">'
  848. . number_format_i18n( $referralsdata['sessions'] ) .
  849. '</span>' .
  850. '</li>';
  851. $i ++;
  852. }
  853. ?>
  854. </ul>
  855. </div>
  856. <?php
  857. $referral_url = 'https://analytics.google.com/analytics/web/#report/trafficsources-referrals/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data );
  858. ?>
  859. <div class="monsterinsights-reports-panel-footer">
  860. <a href="<?php echo $referral_url; ?>" target="_blank" title="<?php echo esc_html__( 'View All Referral Sources', 'google-analytics-for-wordpress' ); ?>" class="monsterinsights-reports-panel-footer-button"><?php echo esc_html__( 'View All Referral Sources', 'google-analytics-for-wordpress' ); ?></a>
  861. </div>
  862. </div>
  863. <?php
  864. }
  865. }
  866. public function get_toppages( $data ) {
  867. if ( ! empty( $data['toppages'] ) ) { ?>
  868. <div class="monsterinsights-reports-1-column-row panel row container-fluid nopadding list-no-icons" style="position: relative;">
  869. <div class="monsterinsights-reports-panel-title">
  870. <?php echo esc_html__( 'Top Posts / Pages', 'google-analytics-for-wordpress' ); ?>
  871. </div>
  872. <div class="monsterinsights-reports-uright-tooltip" data-tooltip-title="<?php echo esc_attr( __( 'Top Posts / Pages', 'google-analytics-for-wordpress' ) ); ?>" data-tooltip-description="<?php echo esc_attr( __( 'This list shows the most viewed posts and pages on your website.', 'google-analytics-for-wordpress' ) ); ?>"></div>
  873. <div id="monsterinsights-report-top-page-list" class="monsterinsights-reports-list">
  874. <ul class="monsterinsights-reports-pages-list list-group">
  875. <?php
  876. $i = 1;
  877. foreach ( $data['toppages'] as $itoppages => $toppagesdata ) {
  878. $hide = $i > 10 ? ' style="display: none;" ' : '';
  879. $protocol = is_ssl() ? 'https://' : 'http://';
  880. $opening = ! empty( $toppagesdata['url'] ) && ! empty( $toppagesdata['hostname'] ) ? '<a href="' . $protocol . esc_attr( $toppagesdata['hostname'] . $toppagesdata['url'] ) . '" target="_blank">' : '';
  881. $closing = ! empty( $opening ) ? '</a>' : '';
  882. echo '<li class="list-group-item monsterinsights-listing-table-row"' . $hide . '>' .
  883. '<span class="monsterinsights-reports-list-count">'
  884. . $i .
  885. '. </span>&nbsp;' .
  886. '<span class="monsterinsights-reports-list-text">'
  887. . $opening
  888. . $toppagesdata['title']
  889. . $closing .
  890. '</span>' .
  891. '<span class="monsterinsights-reports-list-number">' .
  892. number_format_i18n( $toppagesdata['sessions'] ) .
  893. '</span>' .
  894. '</li>';
  895. $i ++;
  896. }
  897. ?>
  898. </ul>
  899. </div>
  900. <?php
  901. $referral_url = 'https://analytics.google.com/analytics/web/#report/content-pages/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data );
  902. ?>
  903. <div class="monsterinsights-reports-panel-footer monsterinsights-reports-panel-footer-large">
  904. <?php echo esc_html__( 'Show', 'google-analytics-for-wordpress' ); ?>&nbsp;
  905. <div class="monsterinsights-reports-show-selector-group btn-group" role="group" aria-label="<?php echo esc_html__( 'How many to show', 'google-analytics-for-wordpress' ); ?>">
  906. <button type="button" data-tid="monsterinsights-report-top-page-list" class="monsterinsights-reports-show-selector-button ten btn btn-default active" disabled="disabled">
  907. 10
  908. </button>
  909. <button type="button" data-tid="monsterinsights-report-top-page-list" class="monsterinsights-reports-show-selector-button twentyfive btn btn-default">
  910. 25
  911. </button>
  912. <button type="button" data-tid="monsterinsights-report-top-page-list" class="monsterinsights-reports-show-selector-button fifty btn btn-default">
  913. 50
  914. </button>
  915. </div>
  916. <a href="<?php echo $referral_url; ?>" target="_blank" title="<?php echo esc_html__( 'View Full Post/Page Report', 'google-analytics-for-wordpress' ); ?>" class="monsterinsights-reports-panel-footer-button alignright" style="margin-right: 20px;"><?php echo esc_html__( 'View Full Post/Page Report', 'google-analytics-for-wordpress' ); ?></a>
  917. </div>
  918. </div>
  919. <?php }
  920. }
  921. }