Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hirokisan/ga4data
GA4 client service wrapper for Go
https://github.com/hirokisan/ga4data
ga4 ga4-api github go golang google-analytics-4 google-analytics-4-api googleanalytics googleanalytics4
Last synced: about 2 months ago
JSON representation
GA4 client service wrapper for Go
- Host: GitHub
- URL: https://github.com/hirokisan/ga4data
- Owner: hirokisan
- License: mit
- Created: 2022-11-09T13:13:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-08T11:54:12.000Z (8 months ago)
- Last Synced: 2024-06-20T11:59:44.018Z (6 months ago)
- Topics: ga4, ga4-api, github, go, golang, google-analytics-4, google-analytics-4-api, googleanalytics, googleanalytics4
- Language: Go
- Homepage: https://pkg.go.dev/github.com/hirokisan/ga4data
- Size: 57.6 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Report Card](https://goreportcard.com/badge/github.com/hirokisan/ga4data)](https://goreportcard.com/report/github.com/hirokisan/ga4data)
[![golangci-lint](https://github.com/hirokisan/bybit/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/hirokisan/bybit/actions/workflows/golangci-lint.yml)
[![test](https://github.com/hirokisan/bybit/actions/workflows/test.yml/badge.svg)](https://github.com/hirokisan/bybit/actions/workflows/test.yml)# ga4data
ga4data is an client service wrapper of Google Analytics Data API (GA4) for the Go programming language.
## Usage
### RunReport
```
import (
"github.com/hirokisan/ga4data"analyticsdata "google.golang.org/api/analyticsdata/v1beta"
)// prepare *analyticsdata.Service by yourself
// e.g. service, err := analyticsdata.NewService(ctx, option.WithHTTPClient(httpClient))propertyID := "properties/xxx"
dimensions := []string{ga4data.DimensionDate}
metrics := []string{ga4data.MetricSessions}
response, err := ga4data.RunReport(ctx, service, propertyID, ga4data.CreateRunReportRequest(
analyticsdata.DateRange{
StartDate: "2022-10-01",
EndDate: "2022-10-01",
},
ga4data.RunReportRequestWithDimensions(dimensions),
ga4data.RunReportRequestWithMetrics(metrics),
))// do as you want
```