{"id":16726873,"url":"https://github.com/tpitale/legato-ex","last_synced_at":"2025-04-10T10:32:06.229Z","repository":{"id":57515574,"uuid":"68989001","full_name":"tpitale/legato-ex","owner":"tpitale","description":"Google Analytics API v4 in Elixir","archived":false,"fork":false,"pushed_at":"2017-07-27T00:06:27.000Z","size":31,"stargazers_count":16,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T09:21:12.391Z","etag":null,"topics":["analytics","api","google","google-analytics","reporting"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/tpitale.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-09-23T04:31:52.000Z","updated_at":"2024-08-09T21:35:41.000Z","dependencies_parsed_at":"2022-08-29T20:22:04.534Z","dependency_job_id":null,"html_url":"https://github.com/tpitale/legato-ex","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/tpitale%2Flegato-ex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpitale%2Flegato-ex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpitale%2Flegato-ex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpitale%2Flegato-ex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpitale","download_url":"https://codeload.github.com/tpitale/legato-ex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248148232,"owners_count":21055547,"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":["analytics","api","google","google-analytics","reporting"],"created_at":"2024-10-12T22:54:50.454Z","updated_at":"2025-04-10T10:32:06.206Z","avatar_url":"https://github.com/tpitale.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Legato\n\nLegato provides query access through the official [Google Analytics Reporting API v4](https://developers.google.com/analytics/devguides/reporting/core/v4/)\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/legato), the package can be installed as:\n\n  1. Add `legato` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [{:legato, \"~\u003e 0.2.0\"}]\n    end\n    ```\n\n  2. Ensure `legato` is started before your application:\n\n    ```elixir\n    def application do\n      [applications: [:legato]]\n    end\n    ```\n\nGet an oauth access token from Google\n\n\"Authorization: Bearer token_here\"\n\nHTTPoison.post \"https://analyticsreporting.googleapis.com/v4/reports:batchGet\", \"{}\", [{\"Authorization\", \"Bearer token_here\"}]\n\n* [x] Collect data into Query struct\n* [x] Convert query into Request JSON, encode with Poison\n* [x] Send request to GA\n* [x] Decode response\n* [x] Parse data into struct\n* [x] support metric expression strings\n* [x] add filters to Query\n* [x] add date ranges to Query\n* [x] add order by to Query\n* [x] add segment_id to Query\n* [x] add Sampling\n* [x] put report struct into named struct\n* [ ] add segments to Query (long goal)\n\n```elixir\nprofile = %Legato.Profile{access_token: oauth2_access_token, view_id: view_id}\n```\n\n```elixir\ndefmodule ExitReport do\n  defstruct :exits, :pageviews, :country\nend\n```\n\n```elixir\nimport Legato.Query\n\nalias Legato.Request\nalias Legato.Report\n\nprofile |\u003e\n  metrics([:exits, :pageviews]) |\u003e\n  dimensions([:country]) |\u003e\n  filter(:exits, :gt, 10) |\u003e\n  between(start_date, end_date) |\u003e # first date range for the query\n  between(another_start_date, another_end_date) |\u003e # adds subsequent date ranges\n  order_by(:pageviews, :descending) |\u003e\n  segment(-3) |\u003e\n  sampling(:small) |\u003e\nRequest.all |\u003e\nReport.as(ExitReport)\n```\n\nIf you'd like to use relative dates, I suggest trying `timex`.\n`segment` with an integer will clear any segments, cannot be mixed with dynamic segments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpitale%2Flegato-ex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpitale%2Flegato-ex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpitale%2Flegato-ex/lists"}