An open API service indexing awesome lists of open source software.

https://github.com/ad/ga4


https://github.com/ad/ga4

ga4 go

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# 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

```go
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)
}
}
```