Skip to content

Precis-Digital/analytics-settings-database

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Analytics Settings Database

This is not an officially supported Google product.

This repository contains code for a Google Cloud Function that loads Universal Google Analytics and Google Analytics 4 settings into a set of BigQuery tables. By default, the function is scheduled to run daily. This creates a daily backup of Google Analytics settings that can be used for a variety of purposes, including restoring settings, auditing setups, and having an extensive change history across accounts.

Requirements

Implementation

  1. Navigate to your Google Cloud project and open Cloud Shell
  2. Enter the following into Cloud Shell:

rm -rf analytics-settings-database && git clone https://github.com/Precis-Digital/analytics-settings-database.git && cd analytics-settings-database && bash deploy.sh

  1. Enter the information when prompted during the deployment process. When asked if unauthenticated invocations should be allowed for the Cloud Function, answer no.
  2. This will create the following:
    • A Cloud Function (2nd gen)
    • A Cloud Scheduler Job
    • A BigQuery dataset with the name “analytics_settings_database”
    • The following tables:
      • ga4_account_summaries
      • ga4_accounts
      • ga4_audiences
      • ga4_android_app_data_streams
      • ga4_conversion_events
      • ga4_custom_dimensions
      • ga4_custom_metrics
      • ga4_dv360_link_proposals
      • ga4_dv360_links
      • ga4_firebase_links
      • ga4_google_ads_links
      • ga4_ios_app_data_streams
      • ga4_measurement_protocol_secrets
      • ga4_properties
      • ga4_web_data_streams
      • ua_account_summaries
      • ua_audiences
      • ua_custom_dimensions
      • ua_custom_metrics
      • ua_filter_links
      • ua_filters
      • ua_goals
      • ua_segments
      • ua_views
  3. Add the service account email generated during the deployment process to your Google Analytics accounts.

Upon completing the implementation process, the settings for your Google Analytics accounts that the API can access will be loaded into BigQuery daily at 11 PM. The frequency with which this happens can be adjusted by modifying the Cloud Scheduler Job created during the deployment process.

(Optional) Deploy Health Checkup Table

This optional table combines several different tables together to quickly see important data related to GA4 properties. The table is set to be updated on a daily basis at 11:30 PM via a scheduled query. The table can be easily connected to a Data Studio dashboard to quickly visualize its data. To create the table and scheduled query, open Cloud Shell and enter the following:


cd analytics-settings-database/health\_checkup && bash deploy.sh

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 61.3%
  • Shell 38.7%