Google Analytics icon

Google Analytics

Use the Google Analytics API

Actions84

Overview

This node integrates with the Google Analytics API, specifically targeting the Admin (V1Alpha) resource for managing Calculated Metrics within a property. The "Update Calculated Metric" operation allows users to modify an existing calculated metric associated with a specified Google Analytics property.

Typical use cases include:

  • Adjusting or correcting calculated metrics definitions without recreating them.
  • Automating updates to calculated metrics as part of a larger analytics workflow.
  • Managing Google Analytics properties programmatically to maintain consistent metric calculations.

For example, a user might update the formula or display name of a calculated metric used in reports to reflect new business logic or measurement standards.

Properties

Name Meaning
Property ID The identifier of the Google Analytics property where the calculated metric exists.
Calculated Metric ID The unique identifier of the calculated metric to update.
Query Parameters Optional parameters to customize the request, including:
- calculatedMetricId: ID for the calculated metric (string)
- entity: Level of data access report (property or account level) (string)
- filter: Expression to filter results (string)
- names: Names of access bindings to retrieve (string)
- pageSize: Maximum number of report tasks to return (number)
- pageToken: Token for fetching next page of results (string)
- showDeleted: Include soft-deleted properties (boolean)
- universalAnalyticsPropertyId: UA property ID to look up connected GA4 property (string)
- updateMask: Comma-separated list of fields to update in snake_case (string)
Request Body JSON object containing the updated details of the calculated metric.

Output

The node outputs a JSON array where each element corresponds to the response from the Google Analytics API for the update operation. The JSON structure reflects the updated calculated metric resource, typically including fields such as:

  • The calculated metric's ID.
  • Updated attributes like name, expression/formula, description, and formatting options.
  • Metadata about the metric's creation and last modification.

No binary data output is involved.

Dependencies

  • Requires valid Google Analytics API OAuth2 credentials configured in n8n.
  • The node uses the Google Analytics Admin API endpoint https://analyticsadmin.googleapis.com/v1alpha.
  • Proper permissions on the Google Analytics property are necessary to perform update operations on calculated metrics.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that the Google Analytics OAuth2 API credentials are properly set up and authorized.
  • Required Parameter Errors: Errors indicating missing "Property ID" or "Calculated Metric ID" mean these inputs must be provided for the update operation.
  • API Errors: Errors returned from the Google Analytics API may indicate permission issues, invalid IDs, or malformed request bodies. Verify the correctness of input parameters and the JSON structure in the request body.
  • Update Mask Usage: If only specific fields should be updated, use the updateMask query parameter correctly formatted in snake_case to avoid unintended overwrites.

Links and References


This summary focuses on the "Update Calculated Metric" operation under the Admin (V1Alpha) resource, describing its purpose, required inputs, expected outputs, dependencies, and common troubleshooting tips based on static analysis of the node's source code and provided property definitions.

Discussion