PHPackages                             torresani/redirectanalytics - 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. torresani/redirectanalytics

ActiveTypo3-cms-extension[Utility &amp; Helpers](/categories/utility)

torresani/redirectanalytics
===========================

Tracks TYPO3 redirects via Google Analytics 4 Measurement Protocol (server-side)

0.5.1(2mo ago)012GPL-2.0-or-laterPHP

Since Mar 11Pushed 2mo agoCompare

[ Source](https://github.com/robertotorresani/redirectanalytics)[ Packagist](https://packagist.org/packages/torresani/redirectanalytics)[ RSS](/packages/torresani-redirectanalytics/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

redirectanalytics – TYPO3 Extension
===================================

[](#redirectanalytics--typo3-extension)

TYPO3 13 extension for server-side redirect tracking via **Google Analytics 4**.

Every time a URL managed by the TYPO3 Redirects module is hit, the extension sends an event directly to GA4 via Measurement Protocol, **before** the browser executes the redirect. This means the hit is counted even for redirects to external sites, with no dependency on any client-side JavaScript tag.

---

Requirements
------------

[](#requirements)

RequirementVersionTYPO313.xPHP8.2+ext:redirectsincluded in TYPO3 core---

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

[](#installation)

Copy the `redirectanalytics/` folder into your project, for example under `packages/redirectanalytics/`, then add the local repository to the root `composer.json`:

```
"repositories": [
    {
        "type": "path",
        "url": "./packages/redirectanalytics"
    }
]
```

Then install and activate:

```
composer require torresani/redirectanalytics:@dev
vendor/bin/typo3 extension:activate redirectanalytics
vendor/bin/typo3 cache:flush
```

---

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

[](#configuration)

### 1. Get your GA4 credentials

[](#1-get-your-ga4-credentials)

**Measurement ID**: go to Google Analytics → Admin → Data Streams → select your web stream. The Measurement ID is shown at the top in the format `G-XXXXXXXXXX`.

**API Secret**: on the same Data Stream page, scroll down to **Measurement Protocol API secrets** → Create → give it any name → copy the generated value. Save it immediately: it will not be shown again.

### 2. Configure the extension

[](#2-configure-the-extension)

Go to **Admin Tools → Settings → Extension Configuration → redirectanalytics** and fill in the fields:

**Google Analytics 4 section**

FieldDescription`measurementId`Your GA4 property Measurement ID, e.g. `G-XXXXXXXXXX``apiSecret`The Measurement Protocol secret created above`pageView`When enabled, sends a standard `page_view` event to GA4. Redirect hits will appear in the standard Pages &amp; Screens report without any custom exploration. Default: disabled`redirectHit`When enabled, sends a custom event to GA4 with the redirect source and destination URLs. Default: enabled`redirectHitName`Name of the custom redirect event sent to GA4. Change it only if you need to align with an existing event naming convention. Default: `redirect_hit``debugMode`When enabled, sends to the GA4 debug endpoint and logs the response. Use only during testing — disable in production`timeoutSeconds`Maximum HTTP timeout for the call to GA4. Default is 2 seconds: a low value ensures a network issue never slows down the redirect**Privacy / Consent section**

FieldDescription`consentStrategy`Consent verification strategy (see below)`consentCookieName`Name of the cookie to check (only for `cookie` strategy)`consentCookieValue`Expected cookie value (only for `cookie` strategy)### 3. Consent strategy

[](#3-consent-strategy)

StrategyBehaviour`always`Always track, no cookie check. Use only if you have no consent banner`cookiebot`Reads the CookieBot `CookieConsent` cookie and tracks only if `statistics:true``cookie`Checks that a specific cookie (configurable name and value) is present. Compatible with Klaro and custom banners`none`Tracking completely disabled without uninstalling the extension#### Klaro note

[](#klaro-note)

Klaro saves consent in **localStorage** by default, which is not accessible server-side. To make it work, add `storageMethod: 'cookie'` to your Klaro configuration so it also writes a `klaro` cookie:

```
var klaroConfig = {
    storageMethod: 'cookie',
    cookieName: 'klaro',
    cookieExpiresAfterDays: 365,
    // ...
};
```

Then set the extension fields as follows:

FieldValue`consentStrategy``cookie``consentCookieName``klaro``consentCookieValue``google-analytics-7` (or the exact service name used in your Klaro config)---

How it works
------------

[](#how-it-works)

```
User hits a redirect URL
            │
            ▼
    TYPO3 ext:redirects
    dispatches RedirectWasHitEvent
            │
            ▼
    RedirectAnalyticsListener
            │
            ├─ ConsentCheckerService
            │    consent denied → skip, normal redirect
            │    consent granted ↓
            ▼
    Ga4MeasurementProtocolService
            │
            ├─ extracts client_id from _ga cookie
            ├─ extracts session_id from _ga_STREAMID cookie
            ├─ extracts real browser User-Agent
            │
            └─ POST /mp/collect → Google Analytics 4
            │
            ▼
    TYPO3 completes HTTP 307 redirect

```

The listener never blocks the redirect: it uses a configurable timeout and catches all exceptions internally, ensuring any GA4 or network issue is completely transparent to the user.

---

GA4 event
---------

[](#ga4-event)

The event is named `redirect_hit` and includes the following parameters:

ParameterContent`source_url`Original URL that received the redirect`destination_url`Destination URL`page_location`Same as source\_url`page_referrer`HTTP referrer of the request`session_id`Extracted from the GA4 stream cookie to associate the event with the correct session`debug_mode`Present only when debugMode is enabledTo find it in GA4: **Reports → Configure → Events** or **Explore → Event Explorer**, filtering by `event_name = redirect_hit`. In DebugView it appears in real time during testing.

---

Enabling debug logs
-------------------

[](#enabling-debug-logs)

Add the following to `config/system/additional.php`:

```
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Torresani']['Redirectanalytics'] = [
    'writerConfiguration' => [
        \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
            \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
                'logFileInfix' => 'redirectanalytics',
            ],
        ],
    ],
];
```

Logs are written to `var/log/typo3_redirectanalytics_*.log`. Monitor them in real time with:

```
tail -f var/log/typo3_redirectanalytics_*.log
```

Possible log messages:

MessageMeaning`extension not configured`Measurement ID or API Secret missing`tracking skipped – no consent`Consent not given, normal redirect proceeds`event sent to GA4`Everything ok, event registered`GA4 returned non-2xx status`GA4 responded with an error`exception while sending`Network or firewall issue---

GDPR notes
----------

[](#gdpr-notes)

The user's IP address is never sent to GA4: the `user_ip_address` parameter is intentionally omitted. GA4 will use the server IP for any aggregate geographic processing. The `client_id` is extracted from the `_ga` cookie when available; if absent, an anonymous hash-based ID is generated that does not persist across sessions. To respect user consent, use the `cookiebot` or `cookie` strategy.

---

File structure
--------------

[](#file-structure)

```
redirectanalytics/
├── Classes/
│   ├── EventListener/
│   │   └── RedirectAnalyticsListener.php      ← PSR-14 hook on RedirectWasHitEvent
│   └── Service/
│       ├── ConsentCheckerService.php           ← cookie consent verification
│       └── Ga4MeasurementProtocolService.php  ← HTTP Measurement Protocol call
├── Configuration/
│   ├── Services.yaml                           ← listener registration in DI container
│   └── ExtensionConfiguration.yaml            ← Extension Manager field definitions
├── ext_conf_template.txt                       ← Extension Manager configuration
├── ext_emconf.php
├── composer.json
└── README.md

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance83

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

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.

###  Release Activity

Cadence

Every ~19 days

Total

2

Last Release

85d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07b17dd9c4733f1edfe904346874411e0f07c5986ab4ca861796b6813483084c?d=identicon)[roberto.torresani](/maintainers/roberto.torresani)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/torresani-redirectanalytics/health.svg)

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

###  Alternatives

[wazum/sluggi

TYPO3 extension for URL slug management with inline editing, auto-sync, locking, access control, and redirects

41515.2k](/packages/wazum-sluggi)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[praetorius/vite-asset-collector

Use AssetCollector to embed frontend assets generated by vite

54299.7k1](/packages/praetorius-vite-asset-collector)[typo3/cms-sys-note

TYPO3 CMS System Notes - Records with messages which can be placed on any page and contain instructions or other information related to a page or section.

116.2M37](/packages/typo3-cms-sys-note)[b13/assetcollector

Asset collector - Add CSS and SVG files and strings as inline style tag/inline svg to the html code.

10123.2k](/packages/b13-assetcollector)[eliashaeussler/typo3-solver

Solver - Extends TYPO3's exception handling with AI generated solutions. Problems can also be solved from command line. Several OpenAI parameters are configurable and prompts and solution providers can be customized as desired.

302.1k](/packages/eliashaeussler-typo3-solver)

PHPackages © 2026

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