analytics

package
v0.0.0-...-a0a3655 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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 (
		 ...
    "go.chromium.org/luci/server/analytics"
    ...
  )

  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 }}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID(c context.Context) string

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

func Snippet

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL