PHPackages                             ensue/ga4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ensue/ga4

ActiveLibrary[API Development](/categories/api)

ensue/ga4
=========

Reporting API for Google analytics V4

v1.2.0(1y ago)0247PHPPHP ^8.2

Since Aug 8Pushed 1y agoCompare

[ Source](https://github.com/ensue-llc/Snap-Ga4)[ Packagist](https://packagist.org/packages/ensue/ga4)[ RSS](/packages/ensue-ga4/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Google analytics 4: Data API v1
===============================

[](#google-analytics-4-data-api-v1)

This package aims to provide methods for working with the Data API v1 of Google Analytics 4.

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

You can install the package using Composer. Run the following command:

```
composer require ensue/ga4

```

### Prerequisites

[](#prerequisites)

PackageMinimum VersionLaravel10php8.1### Configuration and Language Files (Optional)

[](#configuration-and-language-files-optional)

```
php artisan vendor:publish --tag=ga4

```

### Dependencies

[](#dependencies)

Follow the step 1 and 2 provided in [Google Analytics Data API (GA4) QuickStart](https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries). After downloading the service account credentials, store them in the **storage** directory of your Laravel project.

### Environment Changes

[](#environment-changes)

Add the following parameters to your **.env** file:

```
GA4_PROPERTY_ID=
GA4_CREDENTIALS_JSON_PATH=

```

Reporting
=========

[](#reporting)

To grant access to view the data, provide the "client email" access in your Google Analytics account's user management through your admin settings.

Provided methods
----------------

[](#provided-methods)

#### Run single report

[](#run-single-report)

```
GA::runReport($attributes);

```

#### Run Batch Report

[](#run-batch-report)

You can run up to 5 reports simultaneously.

```
GA::runBatchReport($attributes);

```

Request Body
------------

[](#request-body)

### Run single report

[](#run-single-report-1)

Maximum Dimensions allowed: 9
Maximum Metrics allowed: 10

```
$attributes = [
  "date_range" => [
    "start_date" => "Y-m-d"
    "end_date" => "Y-m-d"
  ],
  "dimensions" => [],
  "metrics" => [],
  "dimension_filter" => [FILTER_OPTIONS],
  "metric_filter" => [FILTER_OPTIONS],
  "offset" => integer,
  "limit" => integer,
  "metric_aggregations": [],
  "order_by": [],
  "currency_code": string,
  "return_property_quota": boolean
];

```

### Run Batch Report

[](#run-batch-report-1)

```
$attributes = [
    [
        "title" => string,

    ],
    [
        "title" => string,

    ],
]

```

#### Filter options

[](#filter-options)

```
    "filter" => [
        "field_name" => "{DIMENSION_NAME}"
        "expression" => "{FILTER_EXPRESSION}"
        "expression_data" => []
    ],
    "and_group" => [
        [
            "field_name" => "{DIMENSION_NAME}"
            "expression" => "{FILTER_EXPRESSION}"
            "expression_data" => []
        ]
    ],
    "or_group" => [
        [
            "field_name" => "{DIMENSION_NAME}"
            "expression" => "{FILTER_EXPRESSION}"
            "expression_data" => []
        ]
     ],
     "not_expression" => [
        "field_name" => "{DIMENSION_NAME}"
        "expression" => "{FILTER_EXPRESSION}"
        "expression_data" => []
    ],

```

#### Expression options

[](#expression-options)

##### String filter

[](#string-filter)

```
     "expression" => FilterExpression::STRING_FILTER,
     "expression_data" => [
        "match_type" => MatchType::options
        "value" => "{VALUE}",
        "case_sesitive" => boolean,
     ]

```

##### In list filter

[](#in-list-filter)

```
     "expression" => FilterExpression::IN_LIST_FILTER,
     "expression_data" => [
        "values" => [VALUES],
        "case_sensitive" => boolean,
     ]

```

##### Numeric filter

[](#numeric-filter)

```
     "expression" => FilterExpression::NUMERIC_FILTER,
     "expression_data" => [
        "operation" => Operation::options,
        "value" => [
            "int64" => integer,
            "double" => integer
        ]
     ]

```

##### Between Filter

[](#between-filter)

```
     "expression" => FilterExpression::BETWEEN_FILTER,
     "expression_data" => [
        "from" => [
            "int64" => integer,
            "double" => integer
        ],
        "to" => [
            "int64" => integer,
            "double" => integer
        ]
     ]

```

#### Order by options

[](#order-by-options)

##### Order by dimension

[](#order-by-dimension)

```
    "expression" => OrderBy::DIMENSION,
    "expression_data" => [
        "name" => Dimensions::NAME
    ]

```

##### Order by metric

[](#order-by-metric)

```
    "expression" => OrderBy::METRIC,
    "expression_data" => [
        "name" => Dimensions::NAME
    ]

```

##### Order by pivot

[](#order-by-pivot)

```
    "expression" => OrderBy::PIVOT,
    "expression_data" => [
        "name" => Dimensions::NAME,
        "pivotSelections" => [
            [
                "dimensionName" => string,
                "dimensionValue" => string
            ]
        ]
    ]

```

Contributing
------------

[](#contributing)

Feel free to contribute :)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance44

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~285 days

Total

3

Last Release

445d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/41be2bc4f7692b281ea90b572d99e4617cb2becd68ca99931ca074c7d7d6f67f?d=identicon)[shiva\_ensue](/maintainers/shiva_ensue)

![](https://www.gravatar.com/avatar/2b9a2c6d395662236f382dc68d708cc84ac01493d438a52713266b0bf00a3790?d=identicon)[bipinensue](/maintainers/bipinensue)

![](https://www.gravatar.com/avatar/431c9c457ef18bdabff31dc290756de51120377a426b878007a8e76e1a9e1071?d=identicon)[ensueamar](/maintainers/ensueamar)

---

Top Contributors

[![bipinensue](https://avatars.githubusercontent.com/u/188851020?v=4)](https://github.com/bipinensue "bipinensue (2 commits)")[![shivathapa41](https://avatars.githubusercontent.com/u/82861883?v=4)](https://github.com/shivathapa41 "shivathapa41 (1 commits)")

---

Tags

analyticsEnsue

### Embed Badge

![Health badge](/badges/ensue-ga4/health.svg)

```
[![Health](https://phpackages.com/badges/ensue-ga4/health.svg)](https://phpackages.com/packages/ensue-ga4)
```

###  Alternatives

[irazasyed/laravel-gamp

Send analytics data to Google Analytics from Laravel. A package for GA Measurement Protocol API

3361.6M1](/packages/irazasyed-laravel-gamp)[keen-io/keen-io

A PHP library for reporting events to the Keen IO API

1332.3M7](/packages/keen-io-keen-io)[ins0/google-measurement-php-client

Server-Side PHP Client to communicate to Google Analytics over the Google Measurement Protocol

54355.8k2](/packages/ins0-google-measurement-php-client)[gtmassey/laravel-analytics

Create and run Google Analytics Data API queries in Laravel

3868.4k](/packages/gtmassey-laravel-analytics)[alexwestergaard/php-ga4

PHP Library for Google Analytics 4 with Server Side Tagging

63144.7k1](/packages/alexwestergaard-php-ga4)[mediafigaro/google-analytics-api-symfony

Google Analytics API v4 Symfony

46177.7k](/packages/mediafigaro-google-analytics-api-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
