Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 747 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 747 Bytes

ga4

package for sending events to Google Analytics 4 using the Measurement Protocol

Measurement Protocol (Google Analytics 4) docs reference: https://developers.google.com/analytics/devguides/collection/protocol/ga4

Debugging tools: https://ga-dev-tools.google/ga4/event-builder/

Usage

package main

import (
    "fmt"
    "github.com/ad/ga4"
)

func main() {
    client := ga4.NewGA4Client("G-XXXXXXXXXX", "xxxxxxxxxxxxxxxxxxxxx", "", true)
    err := client.SendEvent(
        ga4.Event{
            Name: "test_event",
            Params: map[string]string{
                "param1": "value1",
                "param2": "value2",
            },
        },
    )
    if err != nil {
        fmt.Println(err)
    }
}