1. Overview
Google Analytics is a web analytics service offered by Google that tracks and reports website and application traffic. It provides insights into user behavior, acquisition channels, and conversion performance.
The GoInsight Google Analytics node leverages the Google Analytics Data API (GA4) to allow you to seamlessly integrate your analytics data into your automated workflows. With this node, you can perform key data retrieval tasks, including:
- Generate Custom Reports: Fetch customized reports by specifying dimensions, metrics, and date ranges to analyze user engagement and performance.
- Search User Activity: Query detailed activity data for all users or a specific user ID over a given period.
2. Prerequisites
Before using this node, you must have a valid Google Analytics account. Specifically, you will need access to a Google Analytics 4 (GA4) property. You may also need appropriate permissions (e.g., Viewer role) on the GA4 property to access its data via the API.
3. Credentials
For a detailed guide on how to obtain and configure credentials, please refer to our official documentation: Credentials Configuration Guide.
4. Supported Operations
Summary
This node allows you to interact with reports and user data within your Google Analytics 4 property.
| Resource | Operation | Description |
|---|---|---|
| Report | Get a Report | Generate customized Google Analytics 4 reports using the Data API runReport method |
| User Data | Search User Data | Search for user activity data in Google Analytics 4 using the Data API runReport method as an alternative to the legacy User Activity API |
Operation Details
Get a Report
Generate customized Google Analytics 4 reports using the Data API runReport method
Input Parameters:
- PropertyId: GA4 property ID (numeric string, e.g., "123456789")
Options:
- Dimensions: Comma-separated dimension list (e.g., "country,city"). Empty for aggregated data
- Metrics: Comma-separated metric list (e.g., "activeUsers,sessions"). Empty defaults to "activeUsers"
- StartDate: Start date (YYYY-MM-DD or relative like "7daysAgo")
- EndDate: End date (YYYY-MM-DD or relative like "today")
- Limit: Maximum number of rows to return (default 10, max 250000)
Output:
- Rows (string-array): Array of report data rows. Each element is a JSON-serialized string containing the dimension values and metric values for that row. The structure of each row depends on the dimensions and metrics requested.
- DimensionHeaders (string-array): Array of dimension names in the order they appear in each row. These headers correspond to the dimension values in the Rows array. Empty array if no dimensions were requested.
- MetricHeaders (string-array): Array of metric names in the order they appear in each row. These headers correspond to the metric values in the Rows array. Defaults to 'activeUsers' if no metrics were specified.
- RowCount (number): The number of rows actually returned in this response. This may be less than TotalRows if the Limit parameter restricts the number of results.
- TotalRows (number): The total number of rows that match the query criteria, regardless of the Limit parameter. Use this to determine if there are more results available beyond the returned RowCount.
- StatusCode (number): HTTP status code indicating the result of the operation. Returns 200 for successful requests, -1 for parameter validation errors, 500 for internal server errors, or other HTTP status codes for API-specific errors.
- ErrorMessage (string): Detailed error message when the operation fails. Contains the specific error description from the Google Analytics API or parameter validation error. Empty string when StatusCode is 200.
Search User Data
Search for user activity data in Google Analytics 4 using the Data API runReport method as an alternative to the legacy User Activity API
Input Parameters:
- PropertyId: GA4 property ID (numeric string, e.g., "123456789")
Options:
- UserId: User ID to filter results (optional, empty for all users)
- StartDate: Start date (YYYY-MM-DD or relative like "7daysAgo")
- EndDate: End date (YYYY-MM-DD or relative like "today")
- Limit: Maximum number of activity records to return (default 100, max 250000)
Output:
- UserActivities (string-array): Array of user activity records. Each element is a JSON-serialized string containing user engagement data including dimensions (date, event, source, device, platform) and metrics (sessions, page views, event count, engagement rate, duration). If UserId filter is applied, each record also includes the userId field.
- TotalCount (number): The total number of user activity records returned in the UserActivities array. This represents the actual number of matching records within the specified date range and limit constraints.
- StatusCode (number): HTTP status code indicating the result of the operation. Returns 200 for successful requests, -1 for parameter validation errors, 500 for internal server errors, or other HTTP status codes for API-specific errors.
- ErrorMessage (string): Detailed error message when the operation fails. Contains the specific error description from the Google Analytics API or parameter validation error. Empty string when StatusCode is 200.
5. Example Usage
This section will guide you through creating a simple workflow to fetch a basic report of active users by country from your Google Analytics 4 property.
The workflow will consist of a Start node, a Google Analytics node, and an Answer node.
- Add the Tool Node
- In the workflow canvas, click the "+" button to add a new node.
- In the pop-up panel, select the "Tools" tab.
- Find and select "Google Analytics" from the list of tools.
- In the "Google Analytics" supported operations list, click "Get a Report" to add the corresponding node to the canvas.
- Configure the Node
- Click on the newly added "Get a Report" node to open its configuration panel on the right.
- Credentials: In the credentials field at the top of the panel, click the dropdown menu and select your pre-configured Google Analytics credential.
- Parameters: Fill in the input parameters to define your report.
- PropertyId: Enter your numeric GA4 Property ID, for example, 123456789.
- Dimensions: To group the data by country, enter country.
- Metrics: To count the number of active users, enter activeUsers.
- StartDate: Leave the default value 7daysAgo to get data for the last week.
- EndDate: Leave the default value today.
- Limit: Leave the default value 10 to get the top 10 countries.
- Run and Verify
- Once all required parameters are correctly filled, the error indicator on the top right of the workflow canvas will disappear.
- Click the "Run" button on the top right of the canvas to execute the workflow.
- After a successful execution, you can click the log icon in the top right corner to view the detailed inputs and outputs of the node, verifying that the operation was successful and the Rows output contains the expected data.
After completing these steps, your entire workflow is configured. When you run it, a report will be retrieved from Google Analytics showing the top 10 countries by active users over the last 7 days.
6. FAQs
Q: Why am I getting a permission denied (403) error?
A: This error usually indicates that the account used for the credential does not have sufficient permissions for the specified GA4 Property ID. Please check the following:
- Correct Property ID: Ensure the PropertyId you entered is correct.
- User Permissions: Verify that the user associated with your credentials has at least the 'Viewer' role for the property in the Google Analytics admin panel.
Q: What are some common dimensions and metrics I can use?
A: Google Analytics offers a wide range of options. Some common ones include:
- Dimensions: country, city, pagePath, eventName, deviceCategory, firstUserSource
- Metrics: activeUsers, sessions, conversions, totalUsers, eventCount, engagementRate
For a complete and up-to-date list, please refer to the official GA4 Data API documentation on dimensions and metrics.
Q: My report is empty (RowCount is 0). What should I check?
A: An empty report can be due to several reasons:
- Date Range: The selected date range (StartDate to EndDate) may have no data. Try using a wider range.
- Invalid Combination: The dimensions and metrics you requested might not be a valid combination or may have no data for the selected period.
- Data Processing Delay: There might be a data processing delay in Google Analytics itself. Data can sometimes take 24-48 hours to appear in reports.
Leave a Reply.