Quickstart

Activate

Decode GA4 needs to be activated for individual projects via Google Cloud Marketplace.

Deploy

Once activated, replacing the options values in one of the following scripts with your specific values will deploy the installer function into your GA4 dataset. Note that the transform_config_template value determines the destination type (external or date-partitioned).

External Table

This is the recommended architecture as it will result in lower storage cost, automated schema evolution for new source data columns/sub-columns and observed event parameter, user property and item parameter values. However it does require you to create a Google Cloud Storage bucket to store the data, and it will process each date into different file sets, so will be slower than the external table configuration.

DECLARE options JSON;

SET options = JSON '''
    {
        "ga4_dataset_id": "project_id.ga4_dataset_name",
        "transform_config_template": "events_external",
        "gcs_bucket_name": "bucketname"
    }
    ''';

EXECUTE IMMEDIATE (
    SELECT `decode-ga4.eu.deploy_installer`(options)
    );

Partitioned Table

This is the quickest approach as it does not require a GCS bucket, and it can process all of the data in one query. However this architecture does not benefit from the cost and automated schema evolution from which the external table architecture benefits. Use this approach for rapid inspection of the the output structure, however the external table architecture is recommended for long-term usage due to multiple benefits.

DECLARE options JSON;

SET options = JSON '''
    {
        "ga4_dataset_id": "project_id.ga4_dataset_name",
        "transform_config_template": "events_partitioned"
    }
    ''';

EXECUTE IMMEDIATE (
    SELECT `decode-ga4.eu.deploy_installer`(options)
    );

Install

The above scripts will deploy the install_decode_ga4 routine into the GA4 dataset identified by the ga4_dataset_id. Execute the installation script by running:

CALL `project_id.ga4_dataset_name.install_decode_ga4`();

This will install Decode GA4 with the selected installation options. See the configuration section for details on the customization options available at installation.

Running install_decode_ga4 will then profile your existing data and build a custom set of functions into a new dataset called decode_analytics_12345678, where analytics_12345678 is the name of your GA4 dataset.

Run

In order to run the transformation with the default options, simply call the routine:

CALL `project_id.decode_analytics_12345678.RUN`();

This will execute the transformation with the transform configuration set by the transform_config.

Schedule

This can be invoked manually, on a schedule or on an event-driven basis. Note that if the RUN routine is invoked and there is no new data detected, only negligible metadata and date scan query costs are incurred.