diff --git a/main.go b/main.go index dcc441f..7268af7 100644 --- a/main.go +++ b/main.go @@ -157,6 +157,9 @@ func serveTracking() http.HandlerFunc { Pages []pirsch.Stats Languages []pirsch.Stats Referrer []pirsch.Stats + Browser []pirsch.Stats + OS []pirsch.Stats + Platform *pirsch.Stats HourlyVisitorsLabels template.JS HourlyVisitorsDps template.JS HourlyVisitorsTodayLabels template.JS @@ -173,6 +176,9 @@ func serveTracking() http.HandlerFunc { tracking.GetPages(startDate, endDate), tracking.GetLanguages(startDate, endDate), tracking.GetReferrer(startDate, endDate), + tracking.GetBrowser(startDate, endDate), + tracking.GetOS(startDate, endDate), + tracking.GetPlatform(startDate, endDate), hourlyVisitorsLabels, hourlyVisitorsDps, hourlyVisitorsTodayLabels, diff --git a/template/tracking.html b/template/tracking.html index 439289b..a7dfc01 100644 --- a/template/tracking.html +++ b/template/tracking.html @@ -137,6 +137,73 @@ +
+

Browser

+ + + + + + + + + {{range $data := .Browser}} + + + + + {{end}} + +
BrowserVisitors
{{if $data.Browser.Valid}}{{$data.Browser.String}}{{else}}(unknown){{end}}{{$data.Visitors}}
+
+
+

Operating System

+ + + + + + + + + {{range $data := .OS}} + + + + + {{end}} + +
OSVisitors
{{if $data.OS.Valid}}{{$data.OS.String}}{{else}}(unknown){{end}}{{$data.Visitors}}
+
+
+

Platform

+ + + + + + + + + + + + + + + + + + + + + + + + + +
PlatformAbsoluteRelative
Desktop{{.Platform.PlatformDesktopVisitors}}{{round (multiply .Platform.PlatformDesktopRelative 100)}} %
Mobile{{.Platform.PlatformMobileVisitors}}{{round (multiply .Platform.PlatformMobileRelative 100)}} %
(unknown){{.Platform.PlatformUnknownVisitors}}{{round (multiply .Platform.PlatformUnknownRelative 100)}} %
+

Page Visits

diff --git a/tracking/statistics.go b/tracking/statistics.go index ab264bf..be1f548 100644 --- a/tracking/statistics.go +++ b/tracking/statistics.go @@ -93,6 +93,39 @@ func GetReferrer(startDate, endDate time.Time) []pirsch.Stats { return referrer } +func GetOS(startDate, endDate time.Time) []pirsch.Stats { + os, err := analyzer.OS(&pirsch.Filter{From: startDate, To: endDate}) + + if err != nil { + logbuch.Error("Error reading OS statistics", logbuch.Fields{"err": err}) + return nil + } + + return os +} + +func GetBrowser(startDate, endDate time.Time) []pirsch.Stats { + browser, err := analyzer.Browser(&pirsch.Filter{From: startDate, To: endDate}) + + if err != nil { + logbuch.Error("Error reading browser statistics", logbuch.Fields{"err": err}) + return nil + } + + return browser +} + +func GetPlatform(startDate, endDate time.Time) *pirsch.Stats { + platform, err := analyzer.Platform(&pirsch.Filter{From: startDate, To: endDate}) + + if err != nil { + logbuch.Error("Error reading platform statistics", logbuch.Fields{"err": err}) + return nil + } + + return platform +} + func GetHourlyVisitors(startDate, endDate time.Time) (template.JS, template.JS) { visitors, err := analyzer.HourlyVisitors(&pirsch.Filter{From: startDate, To: endDate})