gago

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 14 Imported by: 2

README

gago library

Google Analytics for Go

Development

Get package and dependencies via

go get -v github.com/MarkEdmondson1234/gago/gago
go install github.com/MarkEdmondson1234/gago/gago

Tests

Add the json credential file to an environment argument called GAGO_AUTH in your ~/.bash_profile

Then run

go test github.com/MarkEdmondson1234/gago/gago
gago library

Current functions:

  • Authenticate
  • GetAccounts
  • GetAccountSummary
  • GoogleAnalytics
  • WriteCSV

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(file string) (*analyticsreporting.Service, *analytics.Service)

Authenticate Create clients for v4 and v3 Google Analytics API via JSON credentials file file is a filepath pointing to the location of a service credentials json file downloaded from your GCP console Remember to add the service account email to the GA Views you want to download from

func GetAccounts

func GetAccounts(service *ga.Service)

GetAccounts gets the analytics accounts available for this user

func WriteCSV added in v0.2.0

func WriteCSV(report *ParseReport, file *os.File)

WriteCSV Will write out in CSV format

Types

type AccountSummary

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

AccountSummary The account summary return object

func GetAccountSummary

func GetAccountSummary(service *ga.Service) AccountSummary

GetAccountSummary Gets account summary including web properties and viewIds

type GoogleAnalyticsRequest

type GoogleAnalyticsRequest struct {
	Service                                 *ga.Service
	ViewID, Start, End, Dimensions, Metrics string
	MaxRows, PageLimit                      int64
	UseResourceQuotas, AntiSample, Verbose  bool
	// contains filtered or unexported fields
}

GoogleAnalyticsRequest Make a request object to pass to GoogleAnalytics Service needs to be the reportingService from Analytics ViewID is the GA View to fetch from Start and End are strings in YYYY-MM-DD format Metrics is required, a comma separated string of valid ga: prefix Dimensions expects a comma separated string with valid ga: prefix MaxRows set to -1 to fetch all rows available PageLimit set how many pages to fetch each API request batch - default 10000 UseResourceQuotas if using GA360, set this to TRUE to get increased quota limits AntiSample set to true to attempt to antisample data by breaking up into smaller API calls Verbose Prints logs to stdout

type ParseReport

type ParseReport struct {
	ColumnHeaderDimension []string                `json:"dimensionHeaderEntries,omitempty"`
	ColumnHeaderMetrics   []*ga.MetricHeaderEntry `json:"metricHeaderEntries,omitempty"`
	Rows                  []*ParseReportRow       `json:"values,omitempty"`
	DataLastRefreshed     string                  `json:"dataLastRefreshed,omitempty"`
	IsDataGolden          bool                    `json:"isDataGolden,omitempty"`
	Maximums              []string                `json:"maximums,omitempty"`
	Minimums              []string                `json:"minimums,omitempty"`
	RowCount              int64                   `json:"rowCount,omitempty"`
	FetchedRowCount       int64                   `json:"fetchedRowCount,omitempty"`
	SamplesReadCounts     googleapi.Int64s        `json:"samplesReadCounts,omitempty"`
	SamplingSpaceSizes    googleapi.Int64s        `json:"samplingSpaceSizes,omitempty"`
	Totals                []string                `json:"totals,omitempty"`
}

ParseReport A parsed Report after all batching and paging This takes all the API responses and puts it into a single more usable structure

func GoogleAnalytics

func GoogleAnalytics(gagoRequest GoogleAnalyticsRequest) *ParseReport

GoogleAnalytics Make a request to the v4 Reporting API Supply the function a GoogleAnalyticsRequest struct object

type ParseReportRow

type ParseReportRow struct {
	Dimensions []string `json:"dimensions,omitempty"`
	Metrics    []string `json:"metrics,omitempty"`
}

ParseReportRow A parsed row of ParseReport

Jump to

Keyboard shortcuts

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