# Google Analytics 4

## Pipeline Concepts

Before setting up the pipeline, learn about pipeline concepts [here](https://docs.sprinkledata.com/product/ingesting-your-data/pipelines)

## Step by Step Guide

### STEP-1: Configure Connection

To learn about Connection, refer [here](https://docs.sprinkledata.com/product/ingesting-your-data/pipelines)

* Log into the Sprinkle application
* Navigate to Ingest -> Connections Tab -> Setup Sources ->&#x20;
* Select Google Analytics 4
* Provide all the mandatory details
  * *Name*: Name to identify this connection
  * Connect to Google
  * *Advanced Settings*: Refer [here](#advanced-connection-settings)
* After pressing Connect to Google, you will see authorize screen to allow permissions required for sprinkle to read data. Press Allow
* Test Connection
* Create

### STEP-2: Configure Pipeline

To learn about Pipelines, refer [here](https://docs.sprinkledata.com/product/ingesting-your-data/pipelines)

* Navigate to Ingest -> Pipelines Tab -> Setup Sources ->&#x20;
* Select Google Analytics 4
* Provide the name -> Create
* **Choose from saved connections Tab**:&#x20;
  * From the drop-down, select the name of connection created in STEP-2
  * Next: Select Datasets

### STEP-3: Create Dataset

**Datasets Tab**: To learn about Dataset, refer [here](https://docs.sprinkledata.com/product/ingesting-your-data/pipelines). Add Dataset for each report/dataset that you want to integrate, providing the following details

* *Account Id* (Required): GA Account
* *Properties/Apps* (Required): Select Property/Apps available in this account
* Metrics (Required): Select up to 10 metrics
* Dimensions (Optional): Select up to 9 dimensions to aggregate your metrics on
* Dimensions Filter: Dimension filters allow you to ask for only specific dimension values in the report. To learn more, see [Fundamentals of Dimension Filters](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#http_7) for examples. Metrics cannot be used in this filter. Provide the object here like:-\
  "dimensionFilter": { "filter": { "fieldName": "eventName", "stringFilter": { "value": "first\_open" } } }
* Metrics Filter: The filter clause of metrics. Applied after aggregating the report's rows, similar to SQL having-clause. To learn more, see [here](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport#request-body). Dimensions cannot be used in this filter. Provide the object here like:-\
  "metricFilter": { "filter": { "fieldName": "eventCount", "numericFilter": { "value": { "doubleValue": 2 } } } }
* Ingestion Mode (Required)
  * *Snapshot: Every run will pull data from the start date*
  * *Incremental: Every run will pull data from the last successful run onwards*
* *Start Date* (Required): Pull the data from this date: Format is YYYY-MM-DD
* *Destination Schema* (Required): Data warehouse schema where the table will be ingested into
* *Destination Table name* (Required): It is the table name to be created on the warehouse. If not given, sprinkle will create like ds\_\<pipelinename>\_\<tablename>
* *Destination Create Table Clause*: Provide additional clauses to warehouse-create table queries such as clustering, partitioning, and more, useful for optimizing DML statements. [Learn more](https://docs.sprinkledata.com/product/ingesting-your-data/pipelines/databases/features/destination-create-table-clause) on how to use this field.
* Create

### STEP-4: Run and schedule Ingestion

In the **Run & Schedule** ta&#x62;**:**

* Trigger the Job, using Run Now button
* To schedule, enable Auto-Run. Change the frequency if required

### Advanced Connection Settings

* **API Read Timeout (In seconds) :**  Maximum time of inactivity between two data packets when waiting for the server's response. The default value is 30 seconds.
* **API Connection Timeout (In seconds) :** Time period within which a connection between a client and a server must be established.&#x20;
* **Retry Limit :** Number of retries allowed when an API call fails. For example if an API call fails and retry limit is 5 then it will check 5 times for that API call and if it succeeded then it will stop checkin&#x67;**.**
* **Retry Sleep Time (In milliseconds) :** Given time, after which retry should happen in case an API call fails.
* **Incremental Batch Size (In days) :** No. of days in one batch for which data is being downloaded during incremental ingestion.
* **Version :** It gives information about the version of Google Analytics 4 API being used.
* **Max Records :** Field sets the max limit on the number of records that can be downloaded during each API call.&#x20;

### Dataset Fields

User can pick following fields in datasets

* active1DayUsers
* active28DayUsers
* active7DayUsers
* activeUsers
* addToCarts
* adUnitExposure
* averagePurchaseRevenue
* averagePurchaseRevenuePerPayingUser
* averagePurchaseRevenuePerUser
* averageRevenuePerUser
* averageSessionDuration
* bounceRate
* cartToViewRate
* checkouts
* cohortActiveUsers
* cohortTotalUsers
* conversions
* crashAffectedUsers
* crashFreeUsersRate
* dauPerMau
* dauPerWau
* ecommercePurchases
* engagedSessions
* engagementRate
* eventCount
* eventCountPerUsereventsPerSession
* eventValue
* firstTimePurchaserConversionRate
* firstTimePurchasers
* firstTimePurchasersPerNewUser
* itemListClickEvents
* itemListClickThroughRate
* itemListViewEvents
* itemPromotionClickThroughRate
* itemRevenue
* itemsPurchased
* itemViewEvents
* newUsers
* organicGoogleSearchAveragePosition
* organicGoogleSearchClicks
* organicGoogleSearchClickThroughRate
* organicGoogleSearchImpressions
* promotionClicks
* promotionViews
* publisherAdClicks
* publisherAdImpressions
* purchaserConversionRate
* purchaseRevenue
* purchaseToViewRate
* screenPageViews
* screenPageViewsPerSession
* sessionConversionRate
* sessions
* sessionsPerUser
* shippingAmount
* taxAmount
* totalAdRevenue
* totalPurchasers
* totalRevenue
* totalUsers
* transactions
* transactionsPerPurchaser
* userConversionRate
* userEngagementDuration
* wauPerMau
* conversions:purchase
* sessionConversionRate:purchase
* userConversionRate:purchase
