{"id":16111120,"url":"https://github.com/mjpitz/go-ga","last_synced_at":"2025-03-18T09:31:00.783Z","repository":{"id":57548779,"uuid":"304640699","full_name":"mjpitz/go-ga","owner":"mjpitz","description":"Send data to Google Analytics from Go","archived":false,"fork":false,"pushed_at":"2022-11-11T14:57:15.000Z","size":63,"stargazers_count":19,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T18:42:21.125Z","etag":null,"topics":["golang","golang-library","google-analytics"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjpitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-16T13:49:42.000Z","updated_at":"2025-03-02T00:42:13.000Z","dependencies_parsed_at":"2022-08-28T12:21:04.106Z","dependency_job_id":null,"html_url":"https://github.com/mjpitz/go-ga","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjpitz%2Fgo-ga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjpitz%2Fgo-ga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjpitz%2Fgo-ga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjpitz%2Fgo-ga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjpitz","download_url":"https://codeload.github.com/mjpitz/go-ga/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244192544,"owners_count":20413544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","golang-library","google-analytics"],"created_at":"2024-10-09T19:40:25.030Z","updated_at":"2025-03-18T09:31:00.460Z","avatar_url":"https://github.com/mjpitz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-ga\n\nSend data to Google Analytics from Go.\nThis library implements the [measurement protocol] and supports a majority of the parameters.\n\n[![branch workflow](https://github.com/mjpitz/go-ga/workflows/branch/badge.svg?branch=main)](https://github.com/mjpitz/go-ga/actions?query=workflow%3Abranch)\n[![tag workflow](https://github.com/mjpitz/go-ga/workflows/tag/badge.svg)](https://github.com/mjpitz/go-ga/actions?query=workflow%3Atag)\n![](https://www.google-analytics.com/collect?v=1\u0026tid=UA-172921913-1\u0026cid=555\u0026t=pageview\u0026ec=repo\u0026ea=open\u0026dp=%2Fgo-ga\u0026dt=%2Fgo-ga)\n\n[measurement protocol]: https://developers.google.com/analytics/devguides/collection/protocol/v1/reference\n\n## Features\n\n* Sending data to Google Analytics using GET or POST methods\n* Encoding payloads to URLs for embedding\n* Support for decoding url parameters into a struct using tags `url:\"name\"`\n* A simple containerized beacon for reporting on application usage\n\n### Parameter Support\n\nThe majority of the API has been implemented.\nThere is still work to be done around some array and map style data types.\nThe list below tries to document the current parameter support.\nFor more information, see the [parameter reference] documentation.\n\n[parameter reference]: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters\n\n- [x] General\n- [x] User\n- [x] Session\n- [x] Traffic Sources\n- [x] System Info\n- [x] Hit\n- [x] Content Information\n  - [x] Document Location URL\n  - [x] Document Host Name\n  - [x] Document Path\n  - [x] Document Title\n  - [x] Screen Name\n  - [x] Content Group\n  - [x] Link ID\n- [x] Apps\n- [x] Events\n- [x] E-Commerce\n- [ ] Enhanced E-Commerce\n- [x] Social Interactions\n- [x] Timing\n- [x] Exceptions\n- [x] Custom Dimensions / Metrics\n\n## Examples\n\n### Sending data to Google Analytics\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"time\"\n\n    \"github.com/mjpitz/go-ga/client/v1\"\n    \"github.com/mjpitz/go-ga/client/v1/gatypes\"\n)\n\nfunc main() {\n    client := v1.NewClient(\"UA-XXXXXX-1\", \"customUserAgent\")\n    ping := \u0026gatypes.Payload{\n        HitType: \"event\",\n        NonInteractionHit: true,\n        DisableAdvertisingPersonalization: true,\n        Event: gatypes.Event{\n            EventCategory: \"beacon\",\n            EventAction: \"heartbeat\",\n        },\n    }\n    \n    for {\n        if err := client.SendPost(ping); err != nil {\n            log.Fatal(err)\n        }\n        time.Sleep(time.Minute)\n    }\n}\n```\n\n### Encoding a payload for embed\n\n```go\npackage main\n\nimport (\n    \"github.com/mjpitz/go-ga/client/v1\"\n    \"github.com/mjpitz/go-ga/client/v1/gatypes\"\n)\n\nfunc main() {\n    ping := \u0026gatypes.Payload{\n        TrackingID: \"UA-XXXXXX-1\",\n        HitType: \"event\",\n        Event: gatypes.Event{\n            EventCategory: \"email\",\n            EventAction: \"open\",\n        },\n    }\n    \n    url, err := v1.Encode(ping)\n    // do something with url\n}\n```\n\n## Changelog\n\n### v0.1.0\n\nField `TransactionID` was deleted from, `Transaction` and `Item` structs, now it is available at `Payload` struct.\n\nStructs `ScreenView` and `PageView` was merged into `Views`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjpitz%2Fgo-ga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjpitz%2Fgo-ga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjpitz%2Fgo-ga/lists"}