Daniel Siepmann - Coding is Art

TYPO3 Extension: tracking

Purpose of project

I've made this tiny little project in order to have a basic tracking on my own website. I didn't want to include any 3rd party services like Google Analytics. I also didn't want to have any JavaScript involved. Instead the goal was to use all the new technical features within TYPO3.

Current state

Right now the extension tracks all page views. Those are saved in a new database table. Also views of records can be tracked once configured. All entries are available through TYPO3 list module and widgets for EXT:dashboard. Integrators can define a rule for incoming requests which should not be tracked, e.g. logged in backend users.

More information are available at official docs: https://docs.typo3.org/p/danielsiepmann/tracking/1.0/en-us/.

Therefore the following technical parts are used:

  • PSR-7 HTTP Message Interface
  • PSR-11 Container Interface
  • PSR-15 HTTP Handlers
  • TYPO3 Context API
  • Symfony Expression Language

Screenshots

Screenshot of TYPO3 dashbaord widgets, displaying pageview records.
Figure i20: Demonstrates how collected pageviews can be visualized via EXT:dashboard.
Screenshot of TYPO3 list view, displaying pageview records.
Figure i21: Demonstrates how collected pageviews are displayed in TYPO3 list module.

How does it work?

Right now the heart of the extension is a custom middleware DanielSiepmann\Tracking\Middleware\Pageview. That middleware will process incoming requests, check for black listing and add a new pageview entry.

More on middlewares inside of TYPO3 can be read at docs.typo3.org.

That middleware uses Symfony Expression Language to execute a configured rule to check for blacklisted requests. More on that topic can be found at symfony.com.

In order to keep code clean and small, dependency injection is used to resolve dependencies from middleware. The dependency injection is used to provide the rule to check for blacklisting. The rule is defined inside Symfony.yaml, and can be overwritten in custom extensions, e.g. a sitepackage. More about that topic is available at docs.typo3.org, symfony.com and usetypo3.com.

Also two widgets are registered for ext:dashboard. Registering dashboards also is done via Services.yaml. The widgets use again dependency injection, e.g. to inject foreign classes to collect data from database, but also to get configuration, e.g. pages to ignore (startpage) and period of time to display. The extension comes with defaults, which can be overwritten in custom extension. Maybe not the best way, but right now that's working.

Where to get it

The TYPO3 extension is published on GitHub.com as well as on Packagist.org. There is no plan to release on extensions.typo3.org.

I would recommend to either download as zip and install plain, or use composer.

composer require danielsiepmann/tracking