# Google Analytics Input

## <img src="https://hop.apache.org/manual/2.14.0/_images/transforms/icons/google-analytics.svg" alt="Google Analytics Input transform Icon" data-size="line"> Google Analytics Input

### Description <a href="#description" id="description"></a>

The Google Analytics Input transform reads data from a Google Analytics 4 account, using the Google Analytics Data API.

The [GA4 Query Explorer](https://ga-dev-tools.google/ga4/query-explorer/) provides a dedicated website to developing and testing queries with the Google Analytics API (outside of Apache Hop).

| Hop Engine | <sup>✓</sup> |
| ---------- | ------------ |
| Spark      | ?            |
| Flink      | ?            |
| Dataflow   | ?            |

### Configuration

* You need a Google Analytics account with access and sufficient permissions to a GA4 property.
* You need a Google Cloud project with a service account. The Google Analytics api needs to be enabled for this project.

Check the Google Cloud docs for more information on how the [create a service account](https://cloud.google.com/iam/docs/service-accounts-create) and to [set up a project](https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries) for use with the Google Analytics Data API.

### Options

#### Google Analytics Connection Settings

| Option              | Description                                                                                                          |
| ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| Application name    | Enter an application name such as "Apache Hop" or leave the default.                                                 |
| OAuth service email | Your Google Developer Service Account’s Email Address (e.g. "\<random <characters@developer.gserviceaccount.com>>"). |
| Key file            | The path to the P12 private key associated with your OAuth Service account.                                          |
| Property Id         | the GA4 property to read from                                                                                        |

#### Query Definition

| Option                 | Description                                                                                                                                                                        |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Start date (YYYY-MM-DD | Specifies the start date associated with the query. The date must be entered in the following format: YYYY-MM-DD.                                                                  |
| End date (YYYY-MM-DD   | Specifies the end date associated with the query. The date must be entered in the following format: YYYY-MM-DD.                                                                    |
| Dimension              | Specifies the dimension fields for which you want to query. The Google Analytics Data API documentation provides you with a list of valid inputs and metrics that can be combined. |
| Metrics                | Specifies the metrics fields you want returned. At least one metric must be provided.                                                                                              |
| Sort                   | Specifies a dimension field on which to sort.                                                                                                                                      |

#### Fields

Click **Get Fields** to retrieve a list of possible fields based on the query you defined. Click **Preview** to preview data based on the defined query.

#### Limit Size

Limit the number of rows to retrieve for the specified GA4 property to a number of rows. Set the limit size to 0 to fetch all available rows.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.primeur.com/data-shaper-1.21/knowing-the-data-shaper-designer/pipelines/transforms/google-analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
