Documentation
¶
Overview ¶
Package apiservice implements a Google Analytics API client for the Google Analytics Acccount and Filter APIs.
Index ¶
- Constants
- type Account
- type AccountPermissions
- type AccountResults
- type AnalyticsData
- type AnalyticsDataResults
- type ErrorResponse
- type Filter
- type FilterDetail
- type FilterDetailUpdate
- type FilterResults
- type FilterUpdate
- type GoogleAnalytics
- func (service *GoogleAnalytics) CreateFilter(accountID string, filter Filter) (Filter, error)
- func (service *GoogleAnalytics) CreateProfileFilterLink(accountID, profileID, webPropertyID, filterID string) error
- func (service *GoogleAnalytics) GetAccounts() ([]Account, error)
- func (service *GoogleAnalytics) GetAnalyticsData(profileID string, numberOfDays int) (AnalyticsData, error)
- func (service *GoogleAnalytics) GetFilters(accountID string) ([]Filter, error)
- func (service *GoogleAnalytics) GetProfiles(accountID string) ([]Profile, error)
- func (service *GoogleAnalytics) RemoveFilter(accountID, filterID string) error
- func (service *GoogleAnalytics) UpdateFilter(accountID string, filterID string, filter Filter) (Filter, error)
- type Item
- type Link
- type Profile
- type ProfileResults
- type Results
- type TableCell
- type TableColumn
- type TableRow
Constants ¶
const GoogleAnalyticsHostname = "www.googleapis.com"
GoogleAnalyticsHostname contains the hostname of the Google Analytics API const GoogleAnalyticsHostname = "www-googleapis-com-yb0hxtzk6st4.runscope.net"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Item Name string `json:"name"` Type string `json:"type"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Permissions AccountPermissions `json:"permissions"` ChildLink Link `json:"childLink"` }
The Account model contains account details such as the account ID, name and type.
type AccountPermissions ¶
type AccountPermissions struct {
Effective []string `json:"effective"`
}
AccountPermissions contains the effictive permissions for an account.
type AccountResults ¶
AccountResults is response model for Google Analytics Account API requests.
type AnalyticsData ¶ added in v0.3.0
type AnalyticsData struct { Cols []TableColumn `json:"cols"` Rows []TableRow `json:"rows"` }
AnalyticsData represents analytics reports data in columns and rows.
type AnalyticsDataResults ¶ added in v0.3.0
type AnalyticsDataResults struct { Results Data AnalyticsData `json:"dataTable"` }
AnalyticsDataResults is response model for Google Analytics data API requests.
type ErrorResponse ¶
type ErrorResponse struct { Error struct { Errors []struct { Domain string `json:"domain"` Reason string `json:"reason"` Message string `json:"message"` } `json:"errors"` Code int `json:"code"` Message string `json:"message"` } `json:"error"` }
ErrorResponse contains the errors details of a Google Analytics API response.
type Filter ¶
type Filter struct { Item Name string `json:"name"` Type string `json:"type"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` AccountID string `json:"accountId"` ParentLink Link `json:"parentLink"` ExcludeDetails FilterDetail `json:"excludeDetails"` }
A Filter model contains the analytics filter details such as the filter name and type.
type FilterDetail ¶
type FilterDetail struct { Kind string `json:"kind"` Field string `json:"field"` MatchType string `json:"matchType"` ExpressionValue string `json:"expressionValue"` CaseSensitive bool `json:"caseSensitive"` }
The FilterDetail model contains the filter match type (regex, ...) and the filter expression value which is used to filter out unwanted analytics data.
type FilterDetailUpdate ¶ added in v0.4.0
type FilterDetailUpdate struct { Field string `json:"field"` ExpressionValue string `json:"expressionValue"` }
The FilterDetailUpdate model can be used to update the expression value of an existing filter.
type FilterResults ¶
FilterResults is response model for Google Analytics Filter API requests.
type FilterUpdate ¶ added in v0.4.0
type FilterUpdate struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` ExcludeDetails FilterDetailUpdate `json:"excludeDetails"` }
FilterUpdate models can be used to update existing filters.
type GoogleAnalytics ¶
type GoogleAnalytics struct {
// contains filtered or unexported fields
}
GoogleAnalytics offers the ability to interact with the Google Analytics Account and Filters APIs using an authenticated (oAuth) HTTP client.
func New ¶
func New(tokenStore apicredentials.TokenStorer, clientID, clientSecret string) (*GoogleAnalytics, error)
New creates a new Google Analytics api service instance with the given client token provider and clientID and clientSecret. Returns an error if the GoogleAnalytics service could not be instantiated.
func (*GoogleAnalytics) CreateFilter ¶
func (service *GoogleAnalytics) CreateFilter(accountID string, filter Filter) (Filter, error)
CreateFilter creates a new filter for the given account ID.
func (*GoogleAnalytics) CreateProfileFilterLink ¶
func (service *GoogleAnalytics) CreateProfileFilterLink(accountID, profileID, webPropertyID, filterID string) error
CreateProfileFilterLink creates a new filter for the given account ID.
func (*GoogleAnalytics) GetAccounts ¶
func (service *GoogleAnalytics) GetAccounts() ([]Account, error)
GetAccounts returns all accessible accounts from the given API client.
func (*GoogleAnalytics) GetAnalyticsData ¶ added in v0.3.0
func (service *GoogleAnalytics) GetAnalyticsData(profileID string, numberOfDays int) (AnalyticsData, error)
GetAnalyticsData returns analytics data from the given profile/view id.
func (*GoogleAnalytics) GetFilters ¶
func (service *GoogleAnalytics) GetFilters(accountID string) ([]Filter, error)
GetFilters returns all filters for the account with the given account ID.
func (*GoogleAnalytics) GetProfiles ¶
func (service *GoogleAnalytics) GetProfiles(accountID string) ([]Profile, error)
GetProfiles returns all profiles for the account with the given account ID.
func (*GoogleAnalytics) RemoveFilter ¶
func (service *GoogleAnalytics) RemoveFilter(accountID, filterID string) error
RemoveFilter deletes the given filter from the specified account.
func (*GoogleAnalytics) UpdateFilter ¶
func (service *GoogleAnalytics) UpdateFilter(accountID string, filterID string, filter Filter) (Filter, error)
UpdateFilter updates the given filter.
type Item ¶
type Item struct { ID string `json:"id"` Kind string `json:"kind"` SelfLink string `json:"selfLink"` }
Item contains generic attributes of Google Analytics API response objects.
type Profile ¶
type Profile struct { Item AccountID string `json:"accountId"` WebPropertyID string `json:"webPropertyId"` InternalWebPropertyID string `json:"internalWebPropertyId"` Name string `json:"name"` Currency string `json:"currency"` Timezone string `json:"timezone"` WebsiteURL string `json:"websiteUrl"` Type string `json:"type"` }
A Profile model contains the analytics profile details such as the accoun id, name and property ids.
type ProfileResults ¶
ProfileResults is response model for Google Analytics Profile API requests.
type Results ¶
type Results struct { Kind string `json:"kind"` Username string `json:"username"` TotalResults int `json:"totalResults"` StartIndex int `json:"startIndex"` ItemsPerPage int `json:"itemsPerPage"` }
Results contains common attributes of Google Analtics API results.
type TableCell ¶ added in v0.3.0
type TableCell struct {
Value string `json:"v"`
}
TableCell defines analytics data table cell/value.
type TableColumn ¶ added in v0.3.0
type TableColumn struct { ID string `json:"id"` Label string `json:"label"` Type string `json:"type"` }
TableColumn defines analytics data table columns.