Configure the Snowflake Connector for Google Analytics Aggregate Data using SQL¶
This topic provides information about using SQL to configure the Snowflake Connector for Google Analytics Aggregate Data.
Note
The Snowflake Connector for Google Analytics Aggregate Data is typically configured using Snowsight. SQL configuration is considered an advanced configuration method and should only be used by those familiar with the underlying details of connector configuration.
Installation using SQL statements is not supported and must be done via Snowsight.
To configure the connector using SQL statements, complete these tasks:
Note
In order to configure the connector, you must use stored procedures that are defined in the PUBLIC schema of the connector’s installation database.
Before calling these stored procedures, select that database for the session.
For example, if that database is named snowflake_connector_for_google_analytics_aggregate_data, run the following command:
Prepare a warehouse, data owner role, and destination database¶
Grant usage on a specified warehouse and task execution permissions to the connector application:
The connector needs these grants to perform ingestion.
Create a destination database and schema:
Ingested data is stored in the destination schema. You can also use an existing database and schema.
Add required grants on the destination database to the application:
The application needs the grants to create tables for reports data and to create the reports views.
Create the data owner role and add required grants:
Configure the connector¶
Call the
CONFIGURE_CONNECTORprocedure, passing the name of the warehouse, destination database and schema, and data owner role:Note
Values passed to CONFIGURE_CONNECTOR are case-sensitive and should be passed as seen in the UI (for example, as seen in the SHOW command).
Create Snowflake objects required for connecting to GA4¶
To create a security integration for your connection, follow one of these options:
Note
Using a service account is a recommended option.
If you are using a service account, then you need key file. For details on how to create one see Configure service account authentication for Google Cloud. Create a security integration using the details from the key file:
If you are using OAuth2, you need to configure a consent screen and client credentials. For details on how to do that, see Configure OAuth authentication for Google Cloud. Then you need to create security integration:
Create a secret using the security integration:
Note
The secret will securely store the access token generated using the credentials from the security integration.
Provide secret-related grants to the connector application:
If you are using oauth2 authorization, generate a token. Use the link generated by the following code:
You will be redirected to the oauth2 screen. After you accept the required grants, you will be redirected to the endpoint, which completes the oauth2 flow.
Configure external access:
Note
The connector uses the external access integration to communicate with Google Analytics APIs. The network rule controls the list of allowed hosts.
Set the connection configuration¶
Call the
SET_CONNECTION_CONFIGURATIONprocedure, passing the external access integration, the full path to the secret, and the security integration:Note
Values passed to SET_CONNECTION_CONFIGURATION should be unqualified, uppercase identifiers.
Finalize the connector configuration¶
Call the
FINALIZE_CONNECTOR_CONFIGURATIONprocedure:
After the process is completed successfully, ingestion configuration can begin. For more information, see Set up data ingestion for your Snowflake Connector for Google Analytics Aggregate Data instance.