PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 2.3.6
ShareThis Dashboard for Google Analytics v2.3.6
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / view / stats.php
googleanalytics / view Last commit date
ga_accounts_selector.php 9 years ago ga_auth_button.php 9 years ago ga_code.php 6 years ago ga_dashboard_widget.php 9 years ago ga_debug_modal.php 6 years ago ga_googleanalytics_loader.php 6 years ago ga_notice.php 6 years ago ga_oauth_notice.php 9 years ago ga_wp_notice.php 9 years ago page.php 6 years ago statistics.php 6 years ago stats.php 6 years ago trending.php 8 years ago
stats.php
185 lines
1 <?php
2 $account_data = json_decode(get_option('googleanalytics_account_data', true), true);
3 $selected_data = json_decode(get_option('googleanalytics_selected_account', true), true);
4
5 foreach ( $account_data as $properties ) {
6 if ( $properties['id'] === $selected_data[0] ) {
7 foreach ( $properties['webProperties'] as $web_property ) {
8 if ( $web_property['webPropertyId'] === $selected_data[1] ) {
9 $internal_prop = $web_property['internalWebPropertyId'];
10 }
11 }
12 }
13 }
14
15 $sevenorthirty = isset($_GET['th']) ? '30' : '7';
16 $selected7 = '7' === $sevenorthirty ? 'selected' : '';
17 $selected30 = '30' === $sevenorthirty ? 'selected' : '';
18 $selectedpage = isset($_GET['ts']) ? '' : 'selected';
19 $selectedsource = isset($_GET['ts']) ? 'selected' : '';
20 $report_url = 'https://analytics.google.com/analytics/web/#/report/content-pages/a' . $selected_data[0] . 'w' . $internal_prop . 'p' . $selected_data[2];
21 $source_page_url = isset($_GET['ts']) ? str_replace('content-pages', 'trafficsources-all-traffic', $report_url ) : $report_url;
22 $type_label = isset($_GET['ts']) ? 'Traffic Sources' : 'Pages/Posts';
23 $thirty_url = isset($_GET['ts']) ? 'admin.php?page=googleanalytics&th&ts' : 'admin.php?page=googleanalytics&th';
24 $seven_url = isset($_GET['ts']) ? 'admin.php?page=googleanalytics&ts' : 'admin.php?page=googleanalytics';
25 $source_url = isset($_GET['th']) ? 'admin.php?page=googleanalytics&ts&th' : 'admin.php?page=googleanalytics&ts';
26 $page_view_url = isset($_GET['th']) ? 'admin.php?page=googleanalytics&th' : 'admin.php?page=googleanalytics';
27 ?>
28 <div class="wrap ga-wrap" id="ga-stats-container">
29 <?php if ( ! empty( $chart ) ) : ?>
30 <div class="filter-choices">
31 <a href="<?php echo get_admin_url('', $seven_url ); ?>" class="<?php echo esc_attr( $selected7 ); ?>">
32 7 days
33 </a>
34 <a href="<?php echo get_admin_url('', $thirty_url ); ?>" class="<?php echo esc_attr( $selected30 ); ?>">
35 30 days
36 </a>
37 </div>
38 <div class="ga-panel ga-panel-default">
39 <div class="ga-panel-heading">
40 <strong>
41 <?php echo 'Pageviews - Last ' . esc_html( $sevenorthirty ) . ' days'; ?>
42 </strong>
43 </div>
44 <div class="ga-panel-body ga-chart">
45 <div id="chart_div" style="width: 100%;"></div>
46 <div class="ga-loader-wrapper stats-page">
47 <div class="ga-loader stats-page-loader"></div>
48 </div>
49 </div>
50 </div>
51 <?php endif; ?>
52
53 <?php if ( ! empty( $boxes ) ) : ?>
54 <div class="ga-panel ga-panel-default">
55 <div class="ga-panel-heading"><strong><?php echo 'Comparison - Last ' . esc_html( $sevenorthirty ) . ' days vs previous ' . esc_html( $sevenorthirty ) . ' days'; ?></strong>
56 </div>
57 <div class="ga-panel-body">
58 <div class="ga-row">
59 <?php foreach ( $boxes as $box ) : ?>
60 <div class="ga-box">
61 <div class="ga-panel ga-panel-default">
62 <div class="ga-panel-body ga-box-centered">
63 <div class="ga-box-label"><?php echo esc_html( $box['label'] ); ?></div>
64 <div class="ga-box-diff" style="color: <?php echo esc_attr( $box['color'] ); ?>;">
65 <?php echo Ga_Helper::format_percent( $box['diff'] ); ?>
66 </div>
67 <div class="ga-box-comparison"><?php echo $box['comparison']; ?></div>
68 </div>
69 </div>
70 </div>
71 <?php endforeach; ?>
72 </div>
73 </div>
74 </div>
75 <?php endif; ?>
76
77 <?php if ( ! empty( $sources ) ) : ?>
78 <div class="filter-choices">
79 <a href="<?php echo get_admin_url('', $page_view_url); ?>" class="<?php echo esc_attr( $selectedpage ); ?>">
80 Page View
81 </a>
82 <a href="<?php echo get_admin_url('', $source_url); ?>" class="<?php echo esc_attr( $selectedsource ); ?>">
83 Traffic Source
84 </a>
85 </div>
86 <div class="ga-panel ga-panel-default">
87 <div class="ga-panel-heading"><strong><?php _e( "Top 10 " . $type_label . " by page views" ); ?></strong>
88 </div>
89 <div class="ga-panel-body">
90
91 <div id="table-container">
92 <table class="ga-table">
93 <tr>
94 <td colspan="2">
95 </td>
96 <th style="text-align: right;">
97 <?php _e( 'Pageviews' ); ?>
98 </th>
99 <th style="text-align: right;">
100 <?php echo '%'; ?>
101 </th>
102 </tr>
103 <tr>
104 <td colspan="2"></td>
105 <td class="ga-col-pageviews" style="text-align: right">
106 <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
107 <div style="color: grey; font-size: 10px;">% of
108 Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
109 2, '.', ' ' ) : 100 );
110 ?>
111 (<?php echo $sources['sum'] ?>)
112 </div>
113 </td>
114 <td class="ga-col-progressbar" style="text-align: right">
115 <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
116 <div style="color: grey; font-size: 10px;">% of
117 Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
118 2, '.', ' ' ) : 100 );
119 ?>
120 (<?php echo $sources['sum'] ?>)
121 </div>
122 </td>
123 </tr>
124 <?php foreach ( $sources['rows'] as $key => $source ): ?>
125 <tr>
126 <td style="width: 5%;text-align: right"><?php echo $key ?>.</td>
127 <td class="ga-col-name">
128 <?php if ( $source['name'] != '(direct) / (none)' ) :
129
130 $single_breakdown = isset($_GET['ts']) ? '/explorer-table.plotKeys=%5B%5D&_r.drilldown=analytics.sourceMedium:' : '/explorer-table.plotKeys=%5B%5D&_r.drilldown=analytics.pagePath:';
131
132 ?>
133 <a class="ga-source-name" href="<?php echo esc_url( $source_page_url . $single_breakdown . str_replace( '+', '%20', str_replace( '2F', '~2F', str_replace( '%', '', urlencode( $source['url'] ) ) ) ) ); ?>/"
134 target="_blank"><?php echo $source['name'] ?></a>
135 <?php else: ?>
136 <?php echo $source['name'] ?>
137 <?php endif; ?>
138 </td>
139 <td style="text-align: right"><?php echo $source['number'] ?></td>
140 <td>
141 <div class="progress">
142 <div class="progress-bar" role="progressbar"
143 aria-valuenow="<?php echo $source['percent'] ?>" aria-valuemin="0"
144 aria-valuemax="100"
145 style="width: <?php echo $source['percent'] ?>%;"></div>
146 <span style="margin-left: 10px;"><?php echo Ga_Helper::format_percent( $source['percent'] ); ?></span>
147 </div>
148 </td>
149 </tr>
150 <?php endforeach; ?>
151 </table>
152 </div>
153 <a href="<?php echo esc_url( $source_page_url ); ?>/" class="view-report" target="_blank">
154 <?php echo esc_html__('View Full Report' ); ?>
155 </a>
156 </div>
157 </div>
158 <?php endif; ?>
159
160 <?php if ( ! empty( $chart ) ) :
161
162 $label_count = isset($_GET['th']) ? $labels['thisMonth'] : $labels['thisWeek'];
163
164 ?>
165 <script type="text/javascript">
166
167 ga_charts.init(function () {
168
169 var data = new google.visualization.DataTable();
170 data.addColumn('string', 'Day');
171 data.addColumn('number', '<?php echo $label_count ?>');
172 data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
173
174 <?php foreach ( $chart as $row ) : ?>
175 data.addRow(['<?php echo $row['day'] ?>', <?php echo $row['current'] ?>, ga_charts.createTooltip('<?php echo $row['day'] ?>', '<?php echo $row['current'] ?>')]);
176 <?php endforeach; ?>
177 ga_charts.events(data);
178 ga_charts.drawChart(data);
179 ga_loader.hide();
180 }
181 );
182 </script>
183 <?php endif; ?>
184 </div>
185