aboutsummaryrefslogtreecommitdiff
path: root/cmd/site/html.go
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-08-22 03:17:59 +0000
committerChristine Dodrill <me@christine.website>2018-08-22 03:17:59 +0000
commit6b7d6dcc49c6cbd83af70d97d01b700c8fb0c393 (patch)
tree60bd319655e77afb0e3737cc9070d5111a41f22b /cmd/site/html.go
parent5a8b8dc48f33c44fd41ac27c1fb4185de1d87d41 (diff)
downloadxesite-6b7d6dcc49c6cbd83af70d97d01b700c8fb0c393.tar.xz
xesite-6b7d6dcc49c6cbd83af70d97d01b700c8fb0c393.zip
add analytics via segment again
Diffstat (limited to 'cmd/site/html.go')
-rw-r--r--cmd/site/html.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/site/html.go b/cmd/site/html.go
index ba304c5..20be7de 100644
--- a/cmd/site/html.go
+++ b/cmd/site/html.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/Xe/ln"
+ analytics "gopkg.in/segmentio/analytics-go.v3"
)
func logTemplateTime(name string, from time.Time) {
@@ -70,4 +71,12 @@ func (s *Site) showPost(w http.ResponseWriter, r *http.Request) {
}
s.renderTemplatePage("blogpost.html", p).ServeHTTP(w, r)
+
+ if s.segment != nil {
+ s.segment.Enqueue(&analytics.Track{
+ UserId: Hash(r.RemoteAddr, r.Header.Get("X-Forwarded-For")),
+ Event: "Post Viewed",
+ Properties: analytics.NewProperties().SetURL(r.RequestURI).SetTitle(p.Title),
+ })
+ }
}