https://github.com/duyet/gaxy
Google Analytics / Google Tag Manager Proxy
https://github.com/duyet/gaxy
golang google-analytics hacktoberfest proxy
Last synced: about 1 year ago
JSON representation
Google Analytics / Google Tag Manager Proxy
- Host: GitHub
- URL: https://github.com/duyet/gaxy
- Owner: duyet
- License: mit
- Created: 2020-10-01T03:51:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-04T20:23:59.000Z (over 1 year ago)
- Last Synced: 2025-03-28T02:39:05.060Z (about 1 year ago)
- Topics: golang, google-analytics, hacktoberfest, proxy
- Language: Go
- Homepage:
- Size: 436 KB
- Stars: 15
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gaxy
Deployment: https://project-gaxy.appspot.com/ga.js


Google Analytics / Google Tag Manager Proxy by Go.

## Development
Start server in local:
```sh
go run *.go
```
Build binary:
```sh
go build -o gaxy .
./gaxy
```
Testing:
```sh
go test
```
## Installation
### Using Docker
https://github.com/users/duyet/packages/container/package/gaxy
```sh
docker run -it -p 3000:3000 \
-e ROUTE_PREFIX=/analytics \
-e GOOGLE_ORIGIN=https://www.google-analytics.com \
ghcr.io/duyet/gaxy:latest
```
### Using Helm
https://github.com/duyet/charts/tree/master/gaxy
```sh
helm repo add duyet https://duyet.github.io/charts
helm install google-analytics-proxy duyet/gaxy
```
### Using Google App Engine
https://cloud.google.com/appengine/docs/standard/go/quickstart
```sh
# 1. install gcloud
# 2. install app-engine-go component
gcloud components install app-engine-go
# 3. deploy
gcloud app deploy
```
### Environment variables
The following environment values are provided to customize Gaxy:
- `ROUTE_PREFIX`: Gaxy proxy prefix (e.g. `/analytics`). Default **""**
- `GOOGLE_ORIGIN`: Hostname to Google Analytics. Default **https://www.google-analytics.com**
- `INJECT_PARAMS_FROM_REQ_HEADERS`: Convert header fields (if gaxy is behind reverse proxy) to request parameters.
- e.g. `INJECT_PARAMS_FROM_REQ_HEADERS=uip,user-agent` will be add this to the collector URI: `?uip=[VALUE]&user-agent=[VALUE]`
- To rename the key, use `[HEADER_NAME]__[NEW_NAME]` e.g. `INJECT_PARAMS_FROM_REQ_HEADERS=x-email__uip,user-agent__ua`
- List all the parameters of Google Analytics:
- https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
- https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference
- `PORT`: Gaxy webserver port. Default: **8080**
## Usage
```html
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
```
## License
MIT