PHPackages                             heimrichhannot/contao-social-stats-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. heimrichhannot/contao-social-stats-bundle

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

heimrichhannot/contao-social-stats-bundle
=========================================

This bundle collects data about news entries.

0.1.4(3y ago)0102LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Aug 19Pushed 3y ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-social-stats-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-social-stats-bundle)[ RSS](/packages/heimrichhannot-contao-social-stats-bundle/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

Contao Social Stats Bundle
==========================

[](#contao-social-stats-bundle)

This bundle collects data about news entries. Currently it contains a command to update some stats for news articles from some networks.

Features
--------

[](#features)

- following stats are collected:
    - Google Analytics: Unique page view
    - Facebook: share count
    - Matomo: hits

Setup
-----

[](#setup)

### Requirements

[](#requirements)

- PHP 7.2 or higher (not tested with 8.0 and higher)
- Contao 4.4 or higher

Additional:

- Google Analytics: [Google APIs Client Library for PHP ](https://github.com/googleapis/google-api-php-client)

### Install

[](#install)

1. Install with composer or contao manager

    ```
    composer require heimrichhannot/contao-social-stats-bundle

    ```
2. Updated database

    ```
    php vendor/bin/contao-console contao:migrate

    ```
3. Setup a cronjob for SocialStatsCommand (see Usage -&gt; Command for more information)

    ```
    * */1 * * * php vendor/bin/contao-console huh:socialstats:update

    ```

### Configuration

[](#configuration)

Most platforms neeed additions configurtation like access tokens. See configuration reference about what you need.

Usage
-----

[](#usage)

### Command

[](#command)

```
Usage:
  huh:socialstats:update [options]

Options:
  -p, --platforms[=PLATFORMS]  Limit to specific platform/network. See help for more information.
  -l, --limit=LIMIT            Limit the number of news article to update. [default: 20]
  -a, --age=AGE                Limit the age of articles to be updated to a number of days. 0 means no limit. [default: 0]
      --pid=PID                Limit the news articles to given archives. 0 means all archives. [default: 0]
      --dry-run                Don't write anything to the database. API-Calls are still executed.
  -h, --help                   Display this help message
  -q, --quiet                  Do not output any message
  -V, --version                Display this application version
      --ansi                   Force ANSI output
      --no-ansi                Disable ANSI output
  -n, --no-interaction         Do not ask any interactive question
  -e, --env=ENV                The Environment name. [default: "prod"]
      --no-debug               Switches off debug mode.
  -v|vv|vvv, --verbose         Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  This command updates the social statistics of your news entries.

  Following options are available for platforms option:
    fb - Facebook
    ga - Google Analytics
    ma - Matomo

```

### Work with the values

[](#work-with-the-values)

The values collected by the command are written into the `huh_socialstats_values` field of tl\_news. You get them as array after a simple `\Contao\StringUtil::deserialze($newsItemModel->huh_socialstats_values, true)`. The time of the last update of the stats is written into `tl_news.huh_socialstats_last_updated`.

### Google Analytics

[](#google-analytics)

We use the [Google APIs Client Library for PHP ](https://github.com/googleapis/google-api-php-client) to obtain the values. For this to work you need:

- a Google API Console project
- a key file
- a view id

Here you find all informations how to gain these components:

### Add custom news routes

[](#add-custom-news-routes)

By default, the platforms are searched for the default news url (the page you set in the news archive plus an identifier, typical the news alias, see `\Contao\News::generateNewsUrl()`). If you output your news on multiple locations or have some custom routing, you can add or change the urls with `AddNewsArticleUrlsEvent`

```
use HeimrichHannot\SocialStatsBundle\Event\AddNewsArticleUrlsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class SocialStatsEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            AddNewsArticleUrlsEvent::class => 'addNewsArticleUrls',
        ];
    }

    public function addNewsArticleUrls(AddNewsArticleUrlsEvent $event)
    {
        $event->addUrl($event->getBaseUrl().'/my_custom_news_article_route/'.$event->getItem()->id);
    }
}
```

Configuration reference
-----------------------

[](#configuration-reference)

```
# Default configuration for extension with alias: "huh_social_stats"
huh_social_stats:

    # Override the auto-determined base url.
    base_url:             null

    # The start date from which data should be counted. Needed for analytics services like matomo or google analytics. Default values is 2005-01-01 as timestamp.
    start_date:           1104534000
    matomo:

        # Set the matomo url
        url:                  ~

        # The matomo authorization token
        token:                ~
    facebook:

        # The facebook app id.
        app_id:               null

        # The facebook app secret.
        app_secret:           null
    google_analytics:

        # View ID
        view_id:              ~

        # Relative path to the google analytics keyfile.
        key_file:             files/bundles/huh_social_stats/google_analytics/privatekey.json
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~127 days

Total

5

Last Release

1269d ago

PHP version history (2 changes)0.1.0PHP ^7.2

0.1.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-social-stats-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-social-stats-bundle/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-social-stats-bundle)
```

###  Alternatives

[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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