{"id":17968341,"url":"https://github.com/sudo-suhas/example-analyticsreporting","last_synced_at":"2025-03-25T09:30:45.250Z","repository":{"id":83827108,"uuid":"93978295","full_name":"sudo-suhas/example-analyticsreporting","owner":"sudo-suhas","description":"Example for Google Analytics Reporting API v4 in Golang","archived":false,"fork":false,"pushed_at":"2017-10-07T03:00:01.000Z","size":9,"stargazers_count":20,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T00:38:43.418Z","etag":null,"topics":["example-code","google-analytics-api","google-api"],"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/sudo-suhas.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-11T03:03:17.000Z","updated_at":"2022-12-02T14:21:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"a4b3194e-f63e-4d14-9725-2bcb57af480d","html_url":"https://github.com/sudo-suhas/example-analyticsreporting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-suhas%2Fexample-analyticsreporting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-suhas%2Fexample-analyticsreporting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-suhas%2Fexample-analyticsreporting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-suhas%2Fexample-analyticsreporting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudo-suhas","download_url":"https://codeload.github.com/sudo-suhas/example-analyticsreporting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435035,"owners_count":20614817,"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":["example-code","google-analytics-api","google-api"],"created_at":"2024-10-29T14:21:02.354Z","updated_at":"2025-03-25T09:30:45.235Z","avatar_url":"https://github.com/sudo-suhas.png","language":"Go","readme":"# example-analyticsreporting\nExample for Google Analytics Reporting API v4 in golang using the [official client](https://github.com/google/google-api-go-client).\n\nThis example was written using the official examples for [java](https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-java), [python](https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py)\n\n## How to run\n  * Enable the API - Using steps described in https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-java,\n    create a private key `client_secrets.json` and download it to your file system.\n    Also add the new service account to the Google Analytics Account with [Read \u0026 Analyze](https://support.google.com/analytics/answer/2884495) permission.\n  * Clone the repo and install dependencies. [Glide](https://github.com/Masterminds/glide) is preferred.\n    ```\n    $ mkdir -p $GOPATH/src/github.com/sudo-suhas \u0026\u0026 cd $_\n    $ git clone https://github.com/sudo-suhas/example-analyticsreporting.git\n    $ cd example-analyticsreporting\n\n    # preferred method\n    $ glide install\n\n    # or use `go get`\n    $ go get .\n\n    ```\n  * Build the executable binary.\n    ```\n    # This should generate an executable binary in the current folder\n    # Example example-analyticsreporting.exe on windows\n    $ go build .\n\n    ```\n  * You need to pass the location of the `client_secrets.json` file\n    and the Google analytics view ID from the command line.\n    You can use the [Account Explorer](https://ga-dev-tools.appspot.com/account-explorer/) to find a View ID.\n    Additionally, you can pass the flag `--debug` for verbose logging.\n\n    Usage:\n    ```\n    $ ./example-analyticsreporting.exe --help\n    usage: hello_analytics.exe --keyfile=KEYFILE --view-id=VIEW-ID [\u003cflags\u003e]\n\n    Flags:\n          --help             Show context-sensitive help (also try --help-long and\n                            --help-man).\n      -d, --debug            Enable debug mode.\n      -k, --keyfile=KEYFILE  Path to JSON key file.\n      -v, --view-id=VIEW-ID  Google Analytics View ID.\n\n    $ ./example-analyticsreporting.exe --keyfile=E:\\creds\\client_secrets.json -view-id=299792458 --debug\n\n    ```\n\n## File Structure\n  * `hello_analytics.go` - This is the main file. It does the following:\n    - Create a Google Analytics Reporting API v4 service client\n    - Execute a GET analytics report request\n    - Parse and print the response using [`logrus`](https://github.com/Sirupsen/logrus/blob/master/logrus.go).\n  * `debug.go` - This is copied from https://github.com/google/google-api-go-client/blob/master/examples/debug.go.\n    It is used to log the HTTP request and response to `os.Stdout` in debug mode.\n  * `util.go` - This has a simple utility function for tracking function execution time in debug mode.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-suhas%2Fexample-analyticsreporting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudo-suhas%2Fexample-analyticsreporting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-suhas%2Fexample-analyticsreporting/lists"}