<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Mojo::GoogleAnalytics - Extract data from Google Analytics using Mojo
    UserAgent

SYNOPSIS
      my $ga     = Mojo::GoogleAnalytics-&gt;new("/path/to/credentials.json");
      my $report = $ga-&gt;batch_get({
        viewId     =&gt; "ga:152749100",
        dateRanges =&gt; [{startDate =&gt; "7daysAgo", endDate =&gt; "1daysAgo"}],
        dimensions =&gt; [{name =&gt; "ga:country"}, {name =&gt; "ga:browser"}],
        metrics    =&gt; [{expression =&gt; "ga:pageviews"}, {expression =&gt; "ga:sessions"}],
        orderBys   =&gt; [{fieldName =&gt; "ga:pageviews", sortOrder =&gt; "DESCENDING"}],
        pageSize   =&gt; 10,
      });

      print $report-&gt;rows_to_table(as =&gt; "text");

DESCRIPTION
    Mojo::GoogleAnalytics is a Google Analytics client which allow you to
    extract data non-blocking.

    This module is work in progress and currently EXPERIMENTAL. Let me know
    if you start using it or has any feedback regarding the API.

ATTRIBUTES
  authorization
      $hash_ref = $self-&gt;authorization;

    Holds authorization data, extracted by "authorize". This can be useful
    to set from a cache if Mojo::GoogleAnalytics objects are created and
    destroyed frequently, but with the same credentials.

  client_email
      $str = $self-&gt;client_email;

    Example: "some-app@some-project.iam.gserviceaccount.com".

  client_id
      $str = $self-&gt;client_id;

    Example: "103742165385019792511".

  private_key
      $str = $self-&gt;private_key;

    Holds the content of a pem file that looks like this:

      -----BEGIN PRIVATE KEY-----
      ...
      ...
      -----END PRIVATE KEY-----

  ua
      $ua = $self-&gt;ua;
      $self = $self-&gt;ua(Mojo::UserAgent-&gt;new);

    Holds a Mojo::UserAgent object.

METHODS
  authorize
      $self = $self-&gt;authorize;
      $self = $self-&gt;authorize(sub { my ($self, $err) = @_; });

    This method will set "authorization". Note that this method is
    automatically called from inside of "batch_get", unless already
    authorized.

  batch_get
      $report = $self-&gt;batch_get($query);
      $self = $self-&gt;batch_get($query, sub { my ($self, $err, $report) = @_ });

    Used to extract data from Google Analytics. $report will be a
    Mojo::Collection if $query is an array ref, and a single
    Mojo::GoogleAnalytics::Report object if $query is a hash.

    $err is a string on error and false value on success.

  from_file
      $self = $self-&gt;from_file("/path/to/credentials.json");

    Used to load attributes from a JSON credentials file, generated from
    &lt;https://console.developers.google.com/apis/credentials&gt;. Example file:

      {
        "type": "service_account",
        "project_id": "cool-project-238176",
        "private_key_id": "01234abc6780dc2a3284851423099daaad8cff92",
        "private_key": "-----BEGIN PRIVATE KEY-----...\n-----END PRIVATE KEY-----\n",
        "client_email": "some-name@cool-project-238176.iam.gserviceaccount.com",
        "client_id": "103742165385019792511",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://accounts.google.com/o/oauth2/token",
      }

    Note: The JSON credentials file will probably contain more fields than
    is listed above.

  new
      $self = Mojo::GoogleAnalytics-&gt;new(%attrs);
      $self = Mojo::GoogleAnalytics-&gt;new(\%attrs);
      $self = Mojo::GoogleAnalytics-&gt;new("/path/to/credentials.json");

    Used to construct a new Mojo::GoogleAnalytics object. Calling "new()"
    with a single argument will cause "from_file" to be called with that
    argument.

AUTHOR
    Jan Henning Thorsen

COPYRIGHT AND LICENSE
    This program is free software, you can redistribute it and/or modify it
    under the terms of the Artistic License version 2.0.

</pre></body></html>