luci: Index | Files

package analytics

import ""

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 (

  func myHandler(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
    return templates.Args{
		   "Analytics": analytics.Snippet(c),

And in the base html:

{{ .Analytics }}


Package Files

analytics.go doc.go settings.go

func ID Uses

func ID(c context.Context) string

ID returns the Google Analytics ID if it's set, and "" otherwise.

func Snippet Uses

func Snippet(c context.Context) template.HTML

Snippet returns the html snippet for Google Analytics, including the <script> tag and ID, if ID is set.

Package analytics imports 7 packages (graph) and is imported by 3 packages. Updated 2021-01-26. Refresh now. Tools for package owners.