Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
This solution makes it simple to get started with reporting on Core Web Vitals being exported from GA4 into Big Query.
Before you start, you will require the following:
- Website performance data from your being sent to GA4. We suggest using the Web Vitals Template for Google Tag Manager if you don't already have this set up.
- A Google Analytics 4 account, preferably exporting data to BigQuery.
- A Google Cloud Project with a billing account associated with it. This should be the project you are exporting GA4 data to.
You will need the following information to be able to deploy the solution:
- The ID of your Google Cloud project. This can be found on the Google Cloud dashboard in the Project Info section. Be sure to use the ID, not the name.
- The GCP region you will deploy to. This must be the same region you are exporting your GA4 data to. To find the region, open BigQuery Studio, select your project, and select the analytics dataset in the Explorer (it will be named analytics_### where ### is your GA4 property ID). The GCP cloud region is listed in the details under Data location.
- Your GA4 Property ID. This can be found on the GA4 Admin page's Property Settings tab in the Property details box. It is also the numbers at the end of the BigQuery analytics dataset name.
If not already doing so, start exporting the CWV data to BigQuery. Follow the directions in the GA4 documentation.
When you are setting up the export, you must select the daily option. The daily tables are used by the solution, as well as by the standard dashboards. The streaming (a.k.a. intraday) tables are optional.
Once you have CWV data in BigQuery, you can use this solution to create summary tables in BigQuery and have them regularly updated.
Before you can run the deployment script, you must enable the Cloud Resource Manager API. To do this:
- Open the APIs & Services Library by clicking on APIs & Services > Library from the sidebar in the Google Cloud Console.
- Search for "Resource Manager" using the search field on the library welcome page.
- From the search results, select the Cloud Resource Manager API
- Click the Enable button on the Product details page.
To deploy the solution:
- Open a command line shell, either on your local computer or by using the
Google Cloud Shell.
- If you are deploying from your local computer:
- Install the Google Cloud SDK by following the instructions for your platform.
- Update the GCP SDK by running the command
gcloud components update.
- If you are deploying from your local computer:
- Clone the solution git repository using the command
git clone https://github.com/google-marketing-solutions/cwv_from_ga4_exports.git. - Move into the solution directory using the command
cd cwv_from_ga4_exports. - Run the install script with the command
./install. This will install the python packages required and launch the deployment script.- During deployment, when asked if you want to enable Google Cloud
components and APIs, answer
y. - At one point you may be asked to open a URL and paste a version_info string into the console. This is required to schedule updating the materialized table.
- During deployment, when asked if you want to enable Google Cloud
components and APIs, answer
The script will print status messages to the console, including errors if any occur. On error, the script will exit. Otherwise, you will be returned to your prompt upon successful completion.
To update any of the details you entered during the deployment, including CWV thresholds, please re-run the install script.
For security reasons, none of the information you enter is saved outside the deployed container and cannot be reused during subsequent deployments.
Once you have the solution deployed, you should see a table named web_vitals_summary in your GCP project's BigQuery tables. You can use this table along with Data Studio to create dashboards to visualize your CWV progress.
Since creating good dashboards can be difficult, the Chrome DevRel team has released the Web Vitals Connector for Data Studio. The tables created with this solution are compatible with this reusable dashboard. For more information, see the documentation on web.dev.