Skip to content
BlokloDocumentation

Google Analytics

Visit statistics from Google Analytics 4, for example user counts and the most visited pages in the app's dashboard.

Connection type: For the app and the agent. Sign-in: Sign in with a Google account in the provider's window and approve the permissions listed below. No passwords or keys are entered in Bloklo.

How it works

The app and the agent never see the credentials. They call the Google Analytics API through the Bloklo gateway, for example fetch("/gw/<connection id>/v1beta/accountSummaries"). The gateway appends the path to the address https://analyticsdata.googleapis.com, adds an access token from the Google sign-in, renewed automatically, and passes the service's response back to the app.

  • Reads (GET) go through at once. Writes (POST, PUT, PATCH, DELETE) go through at once only when the connection is set to Always allow; otherwise the gateway returns status 202 with an approval_id and the write waits for approval in the panel (see Agent permissions).
  • The Test button sends GET /v1beta/accountSummaries?pageSize=1 and checks that the service accepted the credentials.
Note

Some methods run on another host of the same service (noted in the methods table). Choose that host with the X-Bloklo-Host header, for example X-Bloklo-Host: analyticsadmin.googleapis.com; the gateway accepts only the provider hosts allowed in the connector definition.

Google Analytics 4: the Data API v1beta (base address analyticsdata.googleapis.com) returns reports, and the Admin API v1beta (host analyticsadmin.googleapis.com) lists accounts and properties (property ID in the form properties/123). A report is dimensions, metrics and date ranges; rows are paged with limit (default 10,000, up to 250,000) and offset. Dates are YYYY-MM-DD or NdaysAgo, yesterday, today. The read-only scope (analytics.readonly) is enough for reports and lists.

Before you start

  • A Google account with access to the data the app should use.

Connecting in Bloklo

  1. Open Connectors in the sidebar and find Google Analytics.
  2. Click Connect and enter a connection name in Details.
  3. Click Connect. The Google sign-in window opens.
  4. Choose the Google account and approve the permissions. After approval you return to Bloklo and the connection is active.
  5. Attach the connection to a project: Attach to a project… on the connection page, or describe the task in the project chat.
Note

Until Google verifies the Bloklo app, the sign-in window may warn that the app is unverified. To continue, choose Advanced and then Go to bloklo.com. Until then at most 100 Google accounts can connect.

Provider permissions

Bloklo asks Google for exactly these scopes: https://www.googleapis.com/auth/analytics.readonly. Access can be revoked at any time by removing the connection in Bloklo or in the Google account settings.

Note

The Google account needs access to the GA4 property. Bloklo asks for read access only. Google limit: 200,000 report tokens per day per property.

Google Analytics documentation

Example prompts

Prompts to type in the chat of a project with the connection attached:

  • “Show a chart of visits and users for the last 28 days.”
  • “Build a ranking of the most popular pages with view counts.”
  • “Display the number of active users on the site right now.”

API methods

The most commonly used Google Analytics API methods. The path goes after /gw/<connection id>; parts in braces, such as {id}, are replaced with values. The gateway treats every request other than GET as a write, including queries sent with POST (such as search or GraphQL), so they need approval unless the connection is set to Always allow. The full list of methods is in the provider's documentation.

MethodPathWhat it doesIn the gateway
POST/v1beta/properties/{propertyId}:runReportReport with dimensions and metricswrite (approval)
POST/v1beta/properties/{propertyId}:runRealtimeReportRealtime reportwrite (approval)
POST/v1beta/properties/{propertyId}:batchRunReportsSeveral reports in one requestwrite (approval)
POST/v1beta/properties/{propertyId}:runPivotReportPivot reportwrite (approval)
GET/v1beta/properties/{propertyId}/metadataCatalog of available dimensions and metricsread
POST/v1beta/properties/{propertyId}:checkCompatibilityCheck dimension and metric compatibilitywrite (approval)
GET/v1beta/accountSummariesList GA4 accounts and properties (Admin API host)read
GET/v1beta/properties/{propertyId}/dataStreamsList a property's data streams (Admin API host)read
GET/v1beta/properties/{propertyId}/keyEventsList key events (Admin API host)read

Service limits

Quotas per property (standard property): 200,000 tokens per day (reset at midnight Pacific time), 40,000 per hour, 14,000 per hour per project per property, 10 concurrent requests and 10 server errors per hour per project. Analytics 360: 2,000,000 per day, 400,000 per hour, 140,000 per hour per project, 50 concurrent requests. Quotas apply to core, realtime and funnel reports. Rows: up to 250,000 per request.

Google Analytics API reference

Agent actions and permissions

ActionTypeWhat the agent uses it for
Read datareadFetches data from the service, such as a list of records, to build and check the app. Examples: catalog of available dimensions and metrics; list GA4 accounts and properties (Admin API host); list a property's data streams (Admin API host).
Write datawriteRequests other than GET: creating, changing or deleting data in the service, and also queries sent with POST (such as search). Examples: report with dimensions and metrics; realtime report; several reports in one request.
Tip

By default, reads run without asking and writes need approval in the chat. Change this on the connector page or in Settings → Agent permissions (see Agent permissions).

Troubleshooting

The connection says it needs reconnecting

Access was revoked in the Google account, expired, or the password changed. Open the connection and click Authorize.

The test returns HTTP 403

The account has no access to this data, or some permissions were unticked during sign-in. Reconnect and approve all permissions.

Limits and security

  • One connection can make up to 1,000 requests per minute; the service's own limits also apply.
  • Credentials are encrypted and not shown in the browser after saving; only the names of stored fields are visible.
  • A published app works for every visitor: protect the data the connection gives access to with sign-in in the app.

Something unclear or out of date? Contact us