api

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package api implements an analytics API interface for interacting with the Google Analytics Account and Filter APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API provides CRUD operations for the Google Analytics API.

func (*API) CreateFilter

func (api *API) CreateFilter(accountID string, filterParameters Filter) (Filter, error)

CreateFilter creates a new Filter for the given account ID.

func (*API) GetAccounts

func (api *API) GetAccounts() ([]Account, error)

GetAccounts returns all apiservice.Account models.

func (*API) GetAnalyticsData added in v0.3.0

func (api *API) GetAnalyticsData(accountID string, numberOfDays int) (AnalyticsData, error)

GetAnalyticsData analytics data for the given account ID.

func (*API) GetFilters

func (api *API) GetFilters(accountID string) ([]Filter, error)

GetFilters returns all Filter models for the given account.

func (*API) GetProfiles

func (api *API) GetProfiles(accountID string) ([]Profile, error)

GetProfiles returns all Profile models for the given account.

func (*API) RemoveFilter

func (api *API) RemoveFilter(accountID, filterID string) error

RemoveFilter deletes the given filter from the specified account.

func (*API) UpdateFilter

func (api *API) UpdateFilter(accountID string, filterID string, filterParameters Filter) (Filter, error)

UpdateFilter updates the given filter.

type Account

type Account struct {
	ID   string
	Kind string
	Name string
	Type string
	Link string
}

An Account contains all parameters of an analytics account.

type AnalyticsAPI

type AnalyticsAPI interface {

	// GetAccounts returns all apiservice.Account models.
	GetAccounts() ([]Account, error)

	// GetAnalyticsData analytics data for the given account ID.
	GetAnalyticsData(accountID string, numberOfDays int) (AnalyticsData, error)

	// CreateFilter creates a new Filter for the given account ID.
	CreateFilter(accountID string, filter Filter) (Filter, error)

	// UpdateFilter updates the given filter.
	UpdateFilter(accountID string, filterID string, filter Filter) (Filter, error)

	// GetFilters returns all Filter models for the given account.
	GetFilters(accountID string) ([]Filter, error)

	// GetProfiles returns all Profile models for the given account.
	GetProfiles(accountID string) ([]Profile, error)

	// RemoveFilter deletes the given filter from the specified account.
	RemoveFilter(accountID, filterID string) error
}

The AnalyticsAPI interface provides Analytics API functions.

func New

func New(tokenStore apicredentials.TokenStorer, clientID, clientSecret string) (AnalyticsAPI, error)

New creates a new API instance.

type AnalyticsData added in v0.3.0

type AnalyticsData []AnalyticsDataRow

AnalyticsData is a set of analytics data entries.

type AnalyticsDataRow added in v0.3.0

type AnalyticsDataRow struct {
	// Dimensions
	UserType        string
	FullReferrer    string
	Source          string
	Medium          string
	NetworkDomain   string
	NetworkLocation string
	LandingPagePath string

	// Metrics
	Sessions            int64
	BounceRate          float64
	PageviewsPerSession float64
	TimeOnPage          float64
}

AnalyticsDataRow contains a single analytics data record.

type Filter

type Filter struct {
	AccountID      string
	ID             string
	Kind           string
	Name           string
	Type           string
	Link           string
	ExcludeDetails FilterDetail
}

A Filter contains information about Google Analtics view filters.

func (Filter) Equals

func (filter Filter) Equals(other Filter) bool

Equals checks the this Filter matches the given one.

type FilterDetail

type FilterDetail struct {
	Kind            string
	Field           string
	MatchType       string
	ExpressionValue string
	CaseSensitive   bool
}

A FilterDetail contains the filter type and the expression of a Filter model.

func (FilterDetail) Equals

func (details FilterDetail) Equals(other FilterDetail) bool

Equals checks the this FilterDetail matches the given one.

type Profile

type Profile struct {
	ID   string
	Kind string
	Link string

	AccountID             string
	WebPropertyID         string
	InternalWebPropertyID string
	Name                  string
	Currency              string
	Timezone              string
	WebsiteURL            string
	Type                  string
}

A Profile contains information about Google Analytics views.

type SortAccountsBy

type SortAccountsBy func(account1, account2 Account) bool

SortAccountsBy sorts two Account models.

func (SortAccountsBy) Sort

func (by SortAccountsBy) Sort(accounts []Account)

Sort a slice of Account models.

type SortFiltersBy

type SortFiltersBy func(filter1, filter2 Filter) bool

SortFiltersBy allows to sort Filter models.

func (SortFiltersBy) Sort

func (by SortFiltersBy) Sort(filters []Filter)

Sort a slice of Filter models.

Directories

Path Synopsis
Package apicredentials contains the TokenStorer interface that is used as the oAuth token provider for the Google Analytics API.
Package apicredentials contains the TokenStorer interface that is used as the oAuth token provider for the Google Analytics API.
Package apiservice implements a Google Analytics API client for the Google Analytics Acccount and Filter APIs.
Package apiservice implements a Google Analytics API client for the Google Analytics Acccount and Filter APIs.

Jump to

Keyboard shortcuts

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