ga4

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ga4 is a dumb analytics.Sink over the Google Analytics 4 Measurement Protocol. It maps each analytics event to a GA4 event and POSTs one gzipped batch per flush. Apps that need a different mapping can bring their own sink.

GA4 requires a client_id. This package uses the app-supplied identity from analytics.Tracker.Identify (Event.UserID) when present, falling back to the ephemeral session id — it never synthesises a device identifier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sink

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

Sink delivers events to GA4 via the Measurement Protocol.

func New

func New(measurementID, apiSecret string) *Sink

New returns a GA4 analytics.Sink. measurementID is the "G-XXXX" stream id and apiSecret is a Measurement Protocol API secret.

func (*Sink) Send

func (s *Sink) Send(batch []analytics.Event) error

Send implements analytics.Sink. GA4 accepts up to 25 events per request; a larger batch is split into successive requests.

Jump to

Keyboard shortcuts

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