Documentation
¶
Index ¶
Constants ¶
const ( // GaHTTPS is secure endpoint for Google Analytics measurement protocol API GaHTTPS = "https://" + gaHost + "/" // GaHTTP is non secure endpoint for Google Analytics measurement protocol API GaHTTP = "http://" + gaHost + "/" )
Variables ¶
var ErrNoTrackingID = errors.New("no tracking ID")
ErrNoTrackingID is returned if GA message has no tracking ID
Functions ¶
This section is empty.
Types ¶
type BatchSender ¶
BatchSender sends a batch of messages to analytics provider
type Buffer ¶
Buffer accumulates messages and sends them on Flush() or if limit on queue depth reached
type BufferedClient ¶
BufferedClient accumulates GA messages
func NewBufferedClient ¶
func NewBufferedClient(endpoint string, httpClient *http.Client, onError func(err error)) *BufferedClient
NewBufferedClient creates new buffered client
func (*BufferedClient) Flush ¶
func (api *BufferedClient) Flush() (err error)
Flush sends accumulated messages to GA
func (*BufferedClient) Queue ¶
func (api *BufferedClient) Queue(message Message) error
Queue adds GA message to buffer
func (*BufferedClient) QueueDepth ¶
func (api *BufferedClient) QueueDepth() int
QueueDepth huw many messages accumulated
type Common ¶
type Common struct {
TrackingID string `key:"tid" required:"true"`
ClientID string `key:"cid"`
UserID string `key:"uid"`
UserLanguage string `key:"ul"`
UserAgent string `key:"ua"`
DataSource string `key:"ds"` // https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ds
ApplicationID string `key:"aid"`
}
Common properties of GA message
func (*Common) GetTrackingID ¶
GetTrackingID returns tracking ID of GA message
func (*Common) SetTrackingID ¶
GetTrackingID returns tracking ID of GA message
type Event ¶
type Event struct {
Common
Category string `key:"ec" required:"true"`
Action string `key:"ea" required:"true"`
Label string `key:"el"`
Value uint `key:"ev"`
}
Event is GA message of 'event' type
func NewEventWithLabel ¶
NewEventWithLabel creates new event with label
type Message ¶
type Message interface {
GetTrackingID() string
SetTrackingID(string)
fmt.Stringer
//
Write(w io.Writer) (n int, err error)
}
Message interface should be implemented by all GA messages
type Pageview ¶
type Pageview struct {
Common
//DocumentLocation string `key:"dl"`
DocumentHost string `key:"dh"`
DocumentPath string `key:"dp"`
DocumentTitle string `key:"dt"`
}
Pageview message
func NewPageviewWithDocumentHost ¶
NewPageviewWithDocumentHost creates new pageview message with document host value