Created
February 25, 2019 15:48
-
-
Save szeidler/378bd798c36eab617e31652cd1ac8340 to your computer and use it in GitHub Desktop.
Add summed up numbers to ga_node_reports graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ga_node_reports.pages.inc b/ga_node_reports.pages.inc | |
index f0eb797..8bc4426 100644 | |
--- a/ga_node_reports.pages.inc | |
+++ b/ga_node_reports.pages.inc | |
@@ -39,6 +39,13 @@ function ga_node_reports_view_node_report($node) { | |
// Chart details building. | |
$chart_date = $chart_page = $chart_session = array(); | |
+ // Sum up pageviews and sessions. | |
+ $sum = array('pageviews' => 0, 'sessions' => 0); | |
+ foreach ($results->rows as $records) { | |
+ $sum['pageviews'] += $records['pageviews']; | |
+ $sum['sessions'] += $records['sessions']; | |
+ } | |
+ | |
foreach ($results->rows as $records) { | |
$chart_date[] = date('d-m-y', $records['date']); | |
$chart_page[] = $records['pageviews']; | |
@@ -46,7 +53,10 @@ function ga_node_reports_view_node_report($node) { | |
} | |
// Google chart integration. | |
- $chart_header = array('Pageviews', 'Sessions'); | |
+ $chart_header = array( | |
+ "Pageviews\n Σ: " . $sum['pageviews'], | |
+ "Sessions\n Σ: " . $sum['sessions'], | |
+ ); | |
$chart_rows = array($chart_page, $chart_session); | |
$settings['chart']['pageview_session'] = array( | |
'header' => $chart_date, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment