Skip to content

hirokisan/ga4data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e7f3d69 · May 8, 2024

History

29 Commits
May 8, 2024
Nov 21, 2022
Nov 14, 2022
Nov 12, 2022
May 8, 2024
Nov 9, 2022
May 8, 2024
Nov 26, 2022
May 8, 2024
May 8, 2024
May 8, 2024
Mar 9, 2023
Nov 21, 2022
Mar 9, 2023

Repository files navigation

Go Report Card golangci-lint test

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