PHPackages                             firesphere/google-api - 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. firesphere/google-api

ActiveSilverstripe-module[API Development](/categories/api)

firesphere/google-api
=====================

Connect to the Google Analytics API to get page visits

0.52(6y ago)43.3k3[1 issues](https://github.com/Firesphere/silverstripe-google-api/issues)BSD-3-ClausePHPPHP &gt;=5.6.0

Since Oct 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Firesphere/silverstripe-google-api)[ Packagist](https://packagist.org/packages/firesphere/google-api)[ RSS](/packages/firesphere-google-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

Connect to Google API
=====================

[](#connect-to-google-api)

[![codecov](https://camo.githubusercontent.com/4293cbd77f6ceaf677e90c454d3326509614d77c998add8dfbacfd8f2e82522d/68747470733a2f2f636f6465636f762e696f2f67682f466972657370686572652f73696c7665727374726970652d676f6f676c652d6170692f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Firesphere/silverstripe-google-api)[![Scrutinizer](https://camo.githubusercontent.com/a90317a0d012cd71cb09182b5281d80acd7ed0479b6295da79a8b8965cd4f7ab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466972657370686572652f73696c7665727374726970652d676f6f676c652d6170692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Firesphere/silverstripe-google-api/)[![CircleCI](https://camo.githubusercontent.com/d94d60eea604353fb8883d5c9ba8dc1a3addbb9e6ced23b6de47c5b376e3f8a1/68747470733a2f2f636972636c6563692e636f6d2f67682f466972657370686572652f73696c7665727374726970652d676f6f676c652d6170692f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/Firesphere/silverstripe-google-api/tree/master)[![Maintainability](https://camo.githubusercontent.com/ccaaa88269f129fa43d6b70d09e170459503fa9c09bb38493a37fc0fca1bf97d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38393366636338346436353636346563363463392f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/Firesphere/silverstripe-google-api/maintainability)

Google API
----------

[](#google-api)

The Google API V4 is pretty powerful and supports many different calls to different applications.

The initial use case implemented in this module is, to get the page views for the a set of pages in a given time period and store this count in the database, so that you can sort pages by popularity. There are many features of the google api, that could be included in future updates or extensions of this module.

Further functionality is possible with the given API

Installation
------------

[](#installation)

`composer require firesphere/google-api:dev-master`

And run a `dev/build`

Set up
------

[](#set-up)

First, you will have to set up a Google API application, that is connected to Google Analytics. How to set that up is detailed [In the Google Documentation](https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-php).

Add the absolute path to the key to your `_ss_environment` file:

```
define('SS_ANALYTICS_KEY', 'name-of-my-file');
```

Currently, the OAuth2 integration is not built yet, so for now, add the email address from the downloaded json (key: client\_email) and add this user to your Analytics account. You will need to give it full administrative powers.

Second, copy your `View ID` from the Google Analytics account you want your data from, and put it in the cms under Settings &gt; Google API

Configuration
-------------

[](#configuration)

Create a yml file, or add to an existing config yml the configuration for your update:

```
GoogleAnalyticsReportService:
  begins_with: '/mypage' # Find everything Google knows about children of this page. Can not be used in combination with other configurations
  ends_with: 'mypage' # Find everything Google knows about pages whose URL end with 'mypage', Can not be used in combination with other configurations
  whitelist: # Array of pagetypes you want to search for. Can be combined with blacklist
    - MyPageType
    - MyOtherPageType
  blacklist: # Exclude these pagetypes from being returned
    - MyBlacklistedPage
    - MyOtherBlacklistedPage
```

With multiple filters, it seems Google limits to only the first 20 filters.

If you have multiple filters, you need to set up the batch functionality. By default, the CronTask will do this for you.

The crontask currently does *not* support scheduling, but will probably do so in the future.

Filters are what Google calls "DimensionFilters", which are contained in a "DimensionFilterClause". A filter, at this stage, is a specific page URL.

More on [DimensionFilterClauses and DimensionFilters can be found in the Google Documentation](https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet#DimensionFilterClause).

Did you say Ninja Unicorns?
---------------------------

[](#did-you-say-ninja-unicorns)

```
                                                    /
                                                  .7
                                       \       , //
                                       |\.--._/|//
                                      /\ ) ) ).'/
                                     /(  \  // /
                                    /(   J`((_/ \
                                   / ) | _\     /
                                  /|)  \  eJ    L
                                 |  \ L \   L   L
                                /  \  J  `. J   L
                                |  )   L   \/   \
                               /  \    J   (\   /
             _....___         |  \      \   \```
      ,.._.-'        '''--...-||\     -. \   \
    .'.=.'                    `         `.\ [ Y
   /   /                                  \]  J
  Y / Y                                    Y   L
  | | |          \                         |   L
  | | |           Y                        A  J
  |   I           |                       /I\ /
  |    \          I             \        ( |]/|
  J     \         /._           /        -tI/ |
   L     )       /   /'-------'J           `'-:.
   J   .'      ,'  ,' ,     \   `'-.__          \
    \ T      ,'  ,'   )\    /|        ';'---7   /
     \|    ,'L  Y...-' / _.' /         \   /   /
      J   Y  |  J    .'-'   /         ,--.(   /
       L  |  J   L -'     .'         /  |    /\
       |  J.  L  J     .-;.-/       |    \ .' /
       J   L`-J   L____,.-'`        |  _.-'   |
        L  J   L  J                  ``  J    |
        J   L  |   L                     J    |
         L  J  L    \                    L    \
         |   L  ) _.'\                    ) _.'\
         L    \('`    \                  ('`    \
          ) _.'\`-....'                   `-....'
         ('`    \
          `-.___/

```

License
-------

[](#license)

BSD-3 clause

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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 ~100 days

Recently: every ~174 days

Total

8

Last Release

2427d ago

Major Versions

0.52 → 4.x-dev2019-09-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/8497c885d84e4bf94b8e6136292aa602124a50bbbb4a14ab00e1423f232e7663?d=identicon)[Firesphere](/maintainers/Firesphere)

---

Tags

hacktoberfestapigooglesilverstripeanalyticsninjaNinja UnicornsUnicorns

### Embed Badge

![Health badge](/badges/firesphere-google-api/health.svg)

```
[![Health](https://phpackages.com/badges/firesphere-google-api/health.svg)](https://phpackages.com/packages/firesphere-google-api)
```

###  Alternatives

[mediafigaro/google-analytics-api-symfony

Google Analytics API v4 Symfony

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

Google Analytics for Laravel 4

113108.7k1](/packages/thujohn-analytics)[ozankurt/google-analytics

Laravel Google Analytics

7616.7k](/packages/ozankurt-google-analytics)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

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