Native Google Analytics Data Connector
You are looking at an older version of the documentation. The latest version is found here.
The Google Analytics Data Connector is used to read data from the Google Analytics Data API and make it available in the Data Virtuality Server in the relational form. In this way, you can query a Google Analytics Data via SQL and write complex queries that are directed to multiple different data sources. For example, a single SQL query can join tables from MySQL and combine them with data coming from Google Analytics Data.
Connector Configuration
Metadata
Before issuing the SQL queries to the Google Analytics Data, we need to configure a connection using the SYSADMIN.createConnection()
procedure.
The connection can be created in several ways:
via client email and private key:
CODE
|
via OAuth2 providing a
refreshToken
:
CODE
|
via OAuth2 providing an
authCode
andredirectUri
:
CODE
|
Usage
The Google Analytics Data data is represented as a relational table account
and procedures listProperties
, getMetricsDimensions
and runReport
in the schema named as the alias name given in createDatasource()
.
SELECT Query
To query these tables, a normal SQL select query like the following can be used:
CODE
|
Examples
CODE
|
To get properties, use the listProperties()
stored procedure. Use parent:accounts/
with an account name from accounts
table in filter
parameter:
CODE
|
To get metrics and dimensions, use the getMetricsDimensions
stored procedure.
To get the default metrics and dimensions, use 0
as a value of the propertyId
parameter:
SQL
|
To get the default and custom metrics and dimensions, use the appropriate propertyId
returned by the listProperties
stored procedure:
SQL
|
runReport Procedure
To query actual data from an Analytics account, you can use the runReport
stored procedure.
runReport
with default metrics and dimensions:
CODE
|
runReport
with default and custom metrics and dimensions:
CODE
|
Here is the full list and meaning of the procedure parameters:
Parameter | Description |
---|---|
| Property ID. Available propertyIds can be retrieved from |
| Start date to query data from |
| End date to query data to |
| Date range. You can specify either one date period using the |
| Comma-separated list of requested metrics (specified without the 'ga:' prefix) |
| Comma-separated list of requested dimensions; may be null or skipped |
| Comma-separated list of dimensions or metrics that determine the sort order for Analytics data; may be null or skipped |
| Boolean descending order. Data is sorted in descending order if the parameter is set to |
| Comma-separated list of dimension filters; may be null or skipped |
| Comma-separated list of exclude dimension filters; may be null or skipped |
| Comma-separated list of metric filters; may be null or skipped |
| Currency code; may be null or skipped |
| Boolean. Shows empty rows if set to |
| Offset of record to start returning data from; may be null or skipped |
| Maximum results to return for the request; may be null or skipped |
Formally the procedure returns all possible columns (for all possible default metrics and dimensions and 2 more columns - customMetrics
and customDimensions
. These 2 columns contain arrays of values for custom metrics and dimensions), but for all columns that are not passed with the metrics
and dimensions
parameters, it returns null. To cut off such redundant columns, use the appropriate projection in the SELECT
clause.
Google Analytics Data connector is available since v3.11
getMetricsDimensions
stored procedure is available since v3.13
customMetrics
and customDimensions
columns of the runReport
stored procedure are available since v3.13
authCode
and redirectUri
support is available since v3.13