Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: server/analytics/doc.go

Issue 2248893002: Settings page for analytics ID (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: y Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: server/analytics/doc.go
diff --git a/server/analytics/doc.go b/server/analytics/doc.go
new file mode 100644
index 0000000000000000000000000000000000000000..444b35ec36825b8f750896c489773370d2fa023b
--- /dev/null
+++ b/server/analytics/doc.go
@@ -0,0 +1,38 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+// Package analytics provides a standard way to store the Google Analytics
+// tracking ID.
+//
+// Usage Example
+//
+// This analytics package provides a convenient way to configure an analytics
+// ID for an app. To use, just call analytics.ID(c) and inject that ID
+// into a template.
+//
+// import (
+// ...
+// "github.com/luci/luci-go/server/analytics"
+// ...
+// )
+//
+// func myHandler(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
+// ...
+// return templates.Args{
+// "AnalyticsID": analytics.ID(c),
Vadim Sh. 2016/08/26 21:55:05 add also func Snippet(c context.Context) template
hinoka 2016/08/26 23:11:36 Done.
+// }
+// }
+//
+// And in the base html:
+//
+// {{ if .AnalyticsID }}
+// (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+// (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+// m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+// })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+//
+// ga('create', '{{.AnalyticsID}}', 'auto');
+// ga('send', 'pageview');
+// {{ end }}
+package analytics

Powered by Google App Engine
This is Rietveld 408576698