micheleriva

micheleriva

Using Elixir Google Reporting APIs

Hello everybody!
I’m trying to implement the official Google Analytics Reporting API Elixir package (https://github.com/googleapis/elixir-google-api/tree/master/clients/analytics_reporting) in a personal project, but I can not find any working example out there.
While it’s well documented in the code, it’s still not clear how to properly use those APIs.

Have you ever tried to implement those APIs? Do you know where can I read a working example?
Thanks a lot!

First Post!

darkblueorange

darkblueorange

Hello
Probably a bit late, but I also ran into little documentation / examples.

Here is something that works for me :

...
@googleViewId "ga:XXXXXX"

def google_analytics_authenticate() do
    {:ok, google_bearer_token} = Goth.fetch(YourAppName.Goth)
    google_bearer_token.token
end

def google_analytics_query() do
    conn =
      authenticate()
      |> GoogleApi.AnalyticsReporting.V4.Connection.new()

    {:ok, %Model.GetReportsResponse{reports: [%Model.Report{} = resp]}} =
      conn
      |> Reports.analyticsreporting_reports_batch_get(
        body: %Model.GetReportsRequest{
          reportRequests: [
            %Model.ReportRequest{
              viewId: @googleViewId,
              dateRanges: [
                %Model.DateRange{
                  startDate: "2021-10-05",
                  endDate: "2021-10-22"
                }
              ],
              dimensions: [
                %Model.Dimension{
                  name: "ga:browser"
                },
                %Model.Dimension{
                  name: "ga:sessionDurationBucket"
                }
              ],
              metrics: [%Model.Metric{expression: "ga:users"}]
            }
          ]
        }
      )
    resp
end

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement