PHPackages                             ozdemir/analytics - 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. ozdemir/analytics

ActiveLibrary[API Development](/categories/api)

ozdemir/analytics
=================

Analytics Package for Google Analytics Data API V4

221PHP

Since May 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/n1crack/analytics)[ Packagist](https://packagist.org/packages/ozdemir/analytics)[ RSS](/packages/ozdemir-analytics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Analytics Package
-----------------

[](#analytics-package)

Analytics Package for Google Analytics Data API V4

### Installation

[](#installation)

Run

```
$ composer require ozdemir/analytics
```

### Usage

[](#usage)

```
# Main Library
use Ozdemir\Analytics\Analytics;
use Ozdemir\Analytics\Period;

# Optional reports, you can use these or create your own custom requests.
use Ozdemir\Analytics\Requests\PageViewsByCountry;
use Ozdemir\Analytics\Requests\PageViewsByReferer;

use Ozdemir\Analytics\Requests\PageViews;
use Ozdemir\Analytics\Requests\PageViewsAndUsers;
use Ozdemir\Analytics\Requests\TopBrowsers;
use Ozdemir\Analytics\Requests\TotalUsersByChannels;
use Ozdemir\Analytics\Requests\MostVisitedPages;

$config = [
    'property' => '11111111', // Google Analytics Property ID
    'credentials' => __DIR__ . '/credentials.json'  // credentials.json file path or config array
];

# we load the library
$analytics = new Analytics($config);

# Requests are defined in an array
# Up to 5 requests can be executed in one batch request.
# It is set by Google, so we can't increase this at the moment.
$response = $analytics->fetch([
    new PageViewsByReferer(
        Period::days(7)
    ),

    new PageViewsByCountry(
        Period::days(7),
        5   # row limit, only returns 5 rows
    ),
]);

# We can use the response value as we want.this is quite configurable.
# get($index): index number is the same order of the defined requests above.
# we can also cache the output as we want. It is very easy with the laravel.
return [
    'pageViews' => $response->get(0)->toChartJs(),  // ->toJson() is also available.
    'pageViewsByCountry' => $response->get(1)->toChartJs(),
];
```

#### todo:

[](#todo)

- make a better readme / tutorial
- add unit tests

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0124f2d35be25c3386c1b0614c41112c20313f7b4acc46a502b475d5f6308403?d=identicon)[n1crack](/maintainers/n1crack)

---

Top Contributors

[![n1crack](https://avatars.githubusercontent.com/u/712404?v=4)](https://github.com/n1crack "n1crack (4 commits)")

---

Tags

analyticsapigoogle-analytics

### Embed Badge

![Health badge](/badges/ozdemir-analytics/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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