View Source Plausible.Google.Api (Plausible v0.0.1)

Link to this section Summary

Link to this section Types

Link to this type

google_analytics_view()

View Source
@type google_analytics_view() :: {view_name :: String.t(), view_id :: String.t()}
@type import_auth() ::
  {access_token :: String.t(), refresh_token :: String.t(),
   expires_at :: String.t()}

Link to this section Functions

Link to this function

fetch_and_persist(site, report_request, opts \\ [])

View Source
@spec fetch_and_persist(
  Plausible.Site.t(),
  Plausible.Google.ReportRequest.t(),
  Keyword.t()
) ::
  :ok | {:error, term()}
Link to this function

fetch_stats(site, map, limit)

View Source
Link to this function

fetch_verified_properties(auth)

View Source
Link to this function

get_view(access_token, lookup_id)

View Source
@spec get_view(access_token :: String.t(), lookup_id :: String.t()) ::
  {:ok, google_analytics_view()} | {:ok, nil} | {:error, term()}

Returns a single Google Analytics view if the user has access to it.

Link to this function

import_analytics(site, date_range, view_id, auth)

View Source
@spec import_analytics(Plausible.Site.t(), Date.Range.t(), String.t(), import_auth()) ::
  :ok | {:error, term()}

Imports stats from a Google Analytics UA view to a Plausible site.

This function fetches Google Analytics reports in batches of 7500 per request. The batches are then buffered to Clickhouse by the Plausible.Google.Buffer process.

Requests to Google Analytics can fail, and are retried at most 5 times with an exponential backoff. Returns :ok when importing has finished or {:error, term()} when a request to GA failed too many times.

Useful links:

Link to this function

import_authorize_url(site_id, redirect_to)

View Source
Link to this function

list_views(access_token)

View Source
@spec list_views(access_token :: String.t()) ::
  {:ok, %{required(hostname :: String.t()) => [google_analytics_view()]}}
  | {:error, term()}

Lists Google Analytics views grouped by hostname.

Link to this function

search_console_authorize_url(site_id, redirect_to)

View Source