Google Analytics (GA4) plugin
The Google Analytics plugin allows you to visualize your website data.
There are two Google Analytics data sources, this article covers the v4 version which is most frequently referred to as GA4. Users are being forced from UA to the newer GA4 with UA being end-of-life mid-2023. See Google Analytics UA plugin.
Click the following link for additional content such as blogs, videos, use cases, and more:
Adding a data source
To add a data source, open the relevant workspace and then click on the + next to Data Sources on the left-hand menu in SquaredUp. Search for the data source and click on it to open the Add data source page.
Before you start
Enable the Google Analytics APIs
In the GCP console select your project and ensure that the following are enabled:
- Google Analytics Data API
- Google Analytics Admin API
Configure the GCP Service Account
- Create a new Service Account, or edit an existing account.
See GCP - Creating and managing service accounts. - Ensure the account has the role Viewer by adding the role Basic > Viewer.
See GCP - Grant a single role. - Create a new key for the Service Account using the key type JSON. Download the JSON file, as you will need to copy information from this JSON file when adding the data source.
See GCP - Creating service account keysImportantMake sure to store the key file securely, because it can be used to authenticate as your service account.
Configuring the data source
- Open the JSON file that was downloaded when creating the key.
- Display name:
Give the data source a name. - Client email:
Copy and paste the client_email from the JSON file into the data source form. - Private key:
Copy and paste the private_key from the JSON file into the data source form (everything between the quotes). Restrict access to this data source:
Optionally, enable this toggle if you only want certain users/groups to have access to the data source, or those with the permission to link it to new workspaces. See data source access control for more information.NoteThe term data source here really means data source instance. For example, a user may configure two instances of the AWS data source, one for their development environment and one for production. In that case, each data source instance has its own access control settings.
By default, Restrict access to this data source is set to off. The data source can be viewed, edited and administered by anyone. If you would like to control who has access to this data source, switch Restrict access to this data source to on.
Use the Restrict access to this data source dropdown to control who has access to the workspace:
- By default, the user setting the permissions for the data source will be given Full Control and the Everyone group will be given Link to workspace permissions.
- Tailor access to the data source, as required, by selecting individual users or user groups from the dropdown and giving them Link to workspace or Full Control permissions.
- If the user is not available from the dropdown, you are able to invite them to the data source by typing in their email address and then clicking Add. The new user will then receive an email inviting them to create an account on SquaredUp. Once the account has been created, they will gain access to the organization.
- At least one user or group must be given Full Control.
- Admin users can edit the configuration, modify the Access Control List (ACL) and delete the data source, regardless of the ACL chosen.
See Access control for more information.
Click Test and add to validate the data source configuration. SquaredUp will now attempt to connect using the provided authentication method.
- Testing passed – a success message will be displayed and then the configuration will be saved.
- Testing passed with warnings – warnings will be listed and potential fixes suggested. You can still use the data source with warnings. Select Save with warnings if you believe that you can still use the data source as required with the warnings listed. Alternatively, address the issues listed and then select Rerun tests to validate the data source configuration again. If the validation now passes, click Save.
- Testing Failed – errors will be listed and potential fixes suggested. You cannot use the data source with errors. You are able to select Save with errors if you believe that a system outside of SquaredUp is causing the error that you need to fix. Alternatively, address the issues listed and then select Rerun tests to validate the data source configuration again. If the validation now passes, click Save.
You can edit data source configurations at any time from Settings > Data Sources.
Testing and troubleshooting
If you encounter an error refer to the guidance or contact our support team in-app or via SquaredUp Support
For errors on dashboard tiles see Troubleshooting tiles.
Next steps
Once you've added the data source, you can start creating dashboards to visualize your data using any of the following methods:
- Browse graphs: Click on the Google Analytics data source on the left hand menu, then click on an object to view graphs for the data streams. Click on the three dots at the top right of the graph and then Copy to, to add the graph to a dashboard, then edit if required.
- Data Explorer: Click on the Google Analytics data source on the left hand menu, then click on one of the data streams, such as Page Views. The preconfigured data streams will quickly show you data. Use the Data Explorer to show the data you want, then click Save to dashboard.
- Add a data tile to a dashboard and select either:
- A preconfigured data stream, such as Sessions by Page or Page Views, to quickly see data for the selected object, see Showing page views per day using the Page Views data stream
- A configurable data stream, such as Report Query where you can enter your own query from GA4 Query Explorer, or Metric Query with a metric and dimension.
Data streams
You can use these data streams to create new tiles to show data, or if there are preconfigured dashboards installed you can copy or edit those.
Data streams are named queries targeted at a data source, typically mapped to a specific API endpoint. They define how SquaredUp retrieves live data. By standardizing information from diverse formats into a simple table, data streams provide a consistent starting point regardless of the original source system.
Each plugin includes its own set of data streams. When editing a tile or exploring data, the data stream you choose acts as the entry point to the objects and records within that data source.
Scoped data streams allow you to specify which objects you want to pull data for. Global data streams return general information that is not tied to objects.
Some data streams are configurable, meaning you can configure additional settings on the Parameters tab of the tile editor to create a bespoke query.
When you're creating a tile, you can tweak data streams by grouping or aggregating specific columns.
See Data Streams for more information.
The following data streams are installed with this plugin.
Showing page views per day using the Page Views data stream
- On a dashboard click + and then Data to add a new data tile.
- Data Stream tab:
Select Google Analytics (GA4) then Page Views.
Click on the Objects tab (or click Next). - Objects tab:
Click on the site you want data for.
Click Done. - A suitable visualization is chosen, where possible, but at this point you might like to change the visualization used, see Visualization Settings.
In the right hand pane you can also hide and sort columns,
The Timeframe, Shaping and Columns sections can help you configure the visualization as you need.
For example, to configure the Bar chart for views we will configure the Group by and Aggregation type. - Timeframe tab:
Choose a longer timeframe, for example Current Month - Shaping tab:
Shaping allows you to perform filtering, grouping and sorting operations on the data.
Expand the Group section, and on the Group by drop down select Timestamp, and on the Bucket by drop down select Day.
Change the Aggregation type to Total.Data can be filtered according to whether data in a column meets or does not meet specified text or numerical value conditions.
Multiple filters
You are able to add multiple filter conditions using the following operators:
- AND: All conditions must be satisfied (e.g.
Status-Equals-ClosedANDType-Equals-Question). - OR: Any condition can be satisfied (e.g.
Status-Equals-PendingORStatus-Equals-Closed).
Available filters
The following options are available when filtering data, which ones display depends on the column type.
Use the grouping section to group and aggregate data columns.
For example, for AWS cost data you might configure the following settings to display a table or bar chart of cost per label:
- Group by:
label - Aggregation type:
Total - Aggregation column:
Amount
Which columns are available depends on the data stream you chose.
Configuring grouping enables different visualizations to be displayed, such as bar chart and donut. For example, grouping tickets by channel allows you to show a donut of how many tickets were logged by email vs web form.
Bucket by
If you group by a time column, and further grouping is possible, the Bucket by dropdown appears. Use this field to control how the time data is grouped, for example by
hour,day,monthetc.Aggregation
To aggregate your data, you must select an Aggregation type and a target Aggregation column. For example, if creating bar chart for an Azure Resource Group cost, you could configure the following settings:
- Group by:
Timestamp - Bucket by:
Day - Aggregation type:
Total - Aggregate column:
Cost
The following lists the available aggregation types.
The Sort section allows you to select one or more columns to sort your date by, in either ascending or descending order.
While this sets the default sort order of data, but you can always click on a column heading to sort the data table on the fly.
To sort by multiple columns, click Add sort by to add a new row of sort fields to the list. This allows you perform more complex sorts, such as sorting data by the data it was created, then sorting those results alphabetically.
Enabling the Top toggle allows you to specify the top n rows of data to display.
- AND: All conditions must be satisfied (e.g.
- Optionally, configure Columns.
SquaredUp automatically defines the metadata retrieved from data streams so the data is assigned the correct data type, however in some circumstances you may want to override this.
For example, when retrieving data using the Web API plugin, scripting, or custom query data streams (such as Splunk Enterprise plugin), the assigned data type may not be quite correct or as you expect.
Column settings
Use the following options to format your columns.
Custom formatting
Clicking on a row opens the Configure column window, where you can modify the column name and type. Additionally, you can also supply a format expression to manipulate how the column value is displayed.
For example, you might want to attach a label to a value, combine multiple columns together or display the result of some other calculation.
See Expressions for more.
Custom columns
Custom columns allow you to take any data stream and add completely new columns defined by you. You can provide a value expression when configuring the column to calculate the new column value by leveraging the available data.
NoteIt is currently not possible to reference a custom column via an expression from inside another custom column.
For example, you might want to create a new URL column by entering an expression that combines an address with a ticket ID, or to map data values in order to create state columns.
To add a new custom column, click the Add button under the columns table and select the Custom option. A new column is then added to the list and the Configure column window opens.
See Expressions for more.
Comparison columns
Comparison columns are used to compare two values, for example you may want to compare the number of tickets raised this month to the number of tickets raised last month. You can choose to show the value as an absolute change (for example, 12 more tickets) or as a percentage change (for example, a 28% increase).
When a column has a Type of Number, the Add comparison
button displays at the end of the row, which you can click to open the Add comparison window.
From this window, if you have multiple columns with a Type of Number, you can create a comparison column by doing the following:- Column A:
Select the first column to compare against. Automatically populated with the column of which you clicked Add comparison. - Column B:
Select the second column to compare against. - Output:
Select how to display the comparison value. This value is displayed in the Preview field. Choose from:- Absolute: Show the numerical value of Column A - Column B.
- Percentage: Show the ratio of Column B to Column A as a percent.
- Click Add to create the comparison.
Additional options
Some data types have advanced settings that can be configured in the options section, which is displayed whenever you change the data Type or by clicking expand
next to the column Name. - Column A:
- Optionally, configure Monitoring and KPIs.
- When you have finished click Save.
Configurable data streams
The following data streams installed with this plugin have configurable Parameters.
Page Views (GA4)
Number of page views for this profile (view)
Sessions (GA4)
Number of sessions for this profile (view)
Sessions by Page (GA4)
Number of sessions for this profile (view)
Sessions by Social (GA4)
Number of sessions for this profile (view)
Users (GA4)
Number of unique visitors for this property