google-analytics-proxy

command module
v0.1.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 8 Imported by: 0

README

Google Analytics Proxy

Actions License Releases

Google Analytics Proxy

📊 Transparent proxy for tracking page views with Google Analytics

Installing

A release version Docker image can be pulled by running:

docker pull ghcr.io/joshdk/google-analytics-proxy:v0.1.0

Or, a development version binary can be installed by running:

go install github.com/joshdk/google-analytics-proxy@master

Configuration

This tool uses several environment variables as configuration.

Name Purpose Example
$LISTEN Host and port that the proxy will listen on. 0.0.0.0:8080
$UPSTREAM_ENDPOINT Address of the upstream service to be proxied. https://example.com
$UPSTREAM_HOSTNAME (Optional) Hostname to used when proxying requests to the upstream. example.com
$GOOGLE_ANALYTICS_TRACKING_ID Tracking ID for your Google Analytics property UA-123456789-1
$GOOGLE_ANALYTICS_PROPERTY_NAME Name of your Google Analytics property. example.com
$GOOGLE_ANALYTICS_DRY_RUN (Optional) Disables Google Analytics reporting. true

Usage

To run the Docker image, you can use a command like:

docker run \
  --rm \
  -p 8080:8080 \
  -e LISTEN=0.0.0.0:8080 \
  -e UPSTREAM_ENDPOINT=https://example.com \
  -e UPSTREAM_HOSTNAME=example.com \
  -e GOOGLE_ANALYTICS_PROPERTY_NAME=example.com \
  -e GOOGLE_ANALYTICS_TRACKING_ID=UA-123456789-1 \
    ghcr.io/joshdk/google-analytics-proxy:v0.1.0

Or, to run the local binary, you can use a command like:

LISTEN=0.0.0.0:8080 \
UPSTREAM_ENDPOINT=https://example.com \
UPSTREAM_HOSTNAME=example.com \
GOOGLE_ANALYTICS_PROPERTY_NAME=example.com \
GOOGLE_ANALYTICS_TRACKING_ID=UA-123456789-1 \
  $GOPATH/bin/google-analytics-proxy

Browsing to https://localhost:8080 afterwards will display the proxied upstream.

License

This code is distributed under the MIT License, see LICENSE.txt for more information.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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