Connection
The required arguments to establish a connection are as follows:credentials_file
optional, is a path to the JSON file that stores credentials to the Google account.credentials_json
: optional, is the content of the JSON file that stores credentials to the Google account.property_id
required, is the property id of your Google Analytics website. Here is some information on how to get the property id.
⚠️ One of credentials_file or credentials_json has to be chosen.
If you installed MindsDB locally via pip or cloned it, you need to install all handler dependencies manually. To do so, go to the handler’s folder (mindsdb/integrations/handlers/google_analytics_handler) and run this command:
pip install -r requirements.txt
.You need a Google account in order to use this integration. Here is how to get the credentials file:
-
Create a Google Cloud Platform (GCP) Project:
1.1 Go to the GCP Console (https://console.cloud.google.com/).
1.2 If you haven’t created a project before, you’ll be prompted to do so now.
1.3 Give your new project a name.
1.4 Click
Create
to create the new project. -
Enable the Google Analytics Admin API:
2.1 In the GCP Console, select your project.
2.2 Navigate to
APIs & Services
>Library
. 2.3 In the search bar, search forGoogle Analytics Admin API
. 2.4 Click onGoogle Analytics Admin API
, then clickEnable
. -
Create credentials for the Google Analytics Admin API :
3.1 Navigate to
APIs & Services
>Credentials
. 3.2 Click on theCreate Credentials
button and chooseService account
. 3.3 Enter a uniqueService account ID
. 3.4 ClickDone
. 3.5 Copy the service account you created. Find it underService Accounts
. 3.6 Now click on the service account you created, and navigateKEYS
3.7 ClickADD KEY
>Create new key
. 3.8 ChooseJSON
then clickCREATE
3.9 After this the credentials file will be downloaded directly. Locate the file and use the location to it in thecredentials_file
param. -
Add Service account to Google Analytics Property:
4.1 In the Google Analytics Admin Console, select the Account or Property to which you want to grant access.
4.2 Navigate to the
Admin
panel. 4.3 NavigateAccount
>Account Access Management
. 4.4 Click on the ”+” icon to add a new user. 4.5 Enter the service account you copied in step 3.5 as the email address. 4.6 Assign the appropriate permissions to the service account. At a minimum, you’ll need to grant itEdit
permissions. 4.7 Click on theAdd
button to add the service account as a user with the specified permissions.
Usage
This creates a database that comes with theconversion_events
table.
Now you can use your Google Analytics data like this:
-
searching for conversion events:
-
creating conversion event:
-
updating one conversion event:
-
deleting one conversion event:
For more information about available actions and development plans, visit this page.