Google Analytics

Google Analytics Source Plugin Configuration Reference


This example syncs from Google Analytics to a Postgres destination. The (top level) source spec section is described in the Source Spec Reference.

kind: source
# Common source-plugin configuration
  name: googleanalytics
  path: cloudquery/googleanalytics
  version: "v3.0.9"
  tables: ["*"]
  destinations: ["postgresql"]

  # Google Analytics specific configuration
    property_id: "<YOUR_PROPERTY_ID_HERE>"
      access_token: "<YOUR_OAUTH_ACCESS_TOKEN>"
    - name: example
      - date
      - language
      - country
      - city
      - browser
      - operatingSystem
      - year
      - month
      - hour
      - name: totalUsers
      - name: new_users
        expression: newUsers
      - name: new_users2
        expression: "newUsers + totalUsers"
        invisible: true
      keep_empty_rows: true

Google Analytics Spec

This is the (nested) spec used by the Google Analytics source plugin:

  • property_id (string, required):

    A Google Analytics GA4 property (opens in a new tab) identifier whose events are tracked. To learn more, see where to find your Property ID (opens in a new tab).

    Supported formats:

    • A plain property ID (example: 1234)

    • Prefixed with properties/ (example: properties/1234)

  • start_date (string, optional. Default: date 7 days prior to the sync start):

    A date in YYYY-MM-DD format (example: 2023-05-15). If not specified, the start date will be the one that is 7 days prior to the sync start date.

  • oauth (optional, OAuth spec. Default: empty)

  • reports (required, []report)

  • concurrency (int, optional, default: 10000): A best effort maximum number of Go routines to use. Lower this number to reduce memory usage.

Google Analytics OAuth spec

Google Analytics Data API v1 (opens in a new tab) requires OAuth authorization for scope to run reports.

  • access_token (string, optional. Default: "")

    An access token that you generated authorizing for scope (e.g., by using OAuth 2.0 Playground (opens in a new tab)).

  • client_id (string, optional. Default: "")

    OAuth 2.0 Client ID.

  • client_secret (string, optional. Default: "")

    OAuth 2.0 Client secret.

  • preview backend_options (object) (default: not used)

    Allowed properties are table_name and connection. Use this configuration to enable incremental syncs for supported tables. See more here. Example

    kind: source
      name: googleanalytics
      path: cloudquery/googleanalytics
      version: "v3.0.9"
      destinations: ["postgresql"]
          table_name: "test_state_table"
          connection: "@@plugins.postgresql.connection"

Google Analytics Report spec

Report specification will be transformed into a Google Analytics Data API v1 report (opens in a new tab). The option structure follows:

  • name (string, required)

    Name of the report. It will be translated into a table name as ga_ prefix followed by report name in snake case.

  • dimensions (string array, optional. Default: empty)

    A list of Google Analytics Data API v1 dimensions (opens in a new tab). At most 9 dimensions can be specified per report.

  • metrics (required, []metric)

    A list of Google Analytics Data API v1 metrics (opens in a new tab). Expressions are supported, too.

  • keep_empty_rows (bool, optional. Default: false)

    Whether empty rows should be captured, too.

Google Analytics metric spec

Metric spec that is based on Google Analytics Data API v1 Metric (opens in a new tab) parameter.

  • name (string, required)

    A name or alias (if expression is specified) of the requested metric.

  • expression (string, optional. Default: "")

    A mathematical expression for derived metrics.

  • invisible (boolean, optional. Default: false)

    Indicates if a metric is invisible in the report response. This allows creating more complex requests, while also not saving the intermediate results.