Download the PHP package setono/google-analytics-server-side-tracking-bundle without Composer
On this page you can find all versions of the php package setono/google-analytics-server-side-tracking-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setono/google-analytics-server-side-tracking-bundle
More information about setono/google-analytics-server-side-tracking-bundle
Files in setono/google-analytics-server-side-tracking-bundle
Package google-analytics-server-side-tracking-bundle
Short Description A Symfony bundle that allows you to track your visitors server side instead of client side
License MIT
Informations about the package google-analytics-server-side-tracking-bundle
Symfony Google Analytics Server Side Tracking Bundle
Use this bundle to track your visitors with Google Analytics, but using server side integration instead of the usual client side integration.
This bundle is based on the Google Analytics measurement protocol library which in turn is based on the Universal Analytics solution from Google. The new GA4 tracking solution will be implemented when it's feature complete and out of beta.
Installation
This bundle also depends on the Client Id Bundle and the Consent Bundle, which generates client ids and provides consent services respectively. If you're not bound by the EU cookie laws, take a look at the configuration of the Consent Bundle to have consent granted by default.
To install this bundle, simply run:
This will install the bundle and enable it if you're using Symfony Flex. If you're not using Flex, add the bundle
manually to bundles.php
instead.
Create migration
Hits are saved in the database, so you need to create a migration file:
Configuration
To enable the tracking, you need to supply Google Analytics properties to track:
If you have your properties stored somewhere else, i.e. in a database, you can just implement the
Setono\GoogleAnalyticsServerSideTrackingBundle\Provider\PropertyProviderInterface
which returns a list of properties.
You can also configure the minimum amount of seconds before hits are sent to Google:
Usage
Out of the box, the bundle will start tracking visitors just like the client side integration will, but just as with
the client side integration you may want to add custom tracking specific to your application. Here's an example of
the ecommerce event Purchase
:
Send hits to Google
Use a cronjob to send hits to Google regularly:
No matter the interval in the cronjob, hits will never be sent before the send_delay
has passed (see configuration).
FAQ
How are hit builders persisted?
When creating a hit builder using the hit builder factory, the factory will add the hit builder to the so-called
hit builder stack. A response listener is then persisting the hit builders at the end of the request-response lifecycle.
The same logic as the client side library is applied. This means that page views are persisted when the HTTP status code
is one of 2xx
, 4xx
, or 5xx
. All events are persisted no matter what, though. You can see this logic here.
Do I have to populate request/response parameters?
No. Out of the box, hit builders are populated with request and response parameters, i.e. the url, user agent, document title etc.
All versions of google-analytics-server-side-tracking-bundle with dependencies
doctrine/doctrine-bundle Version ^1.12 || ^2.2
doctrine/orm Version ^2.7
doctrine/persistence Version ^1.3 || ^2.2
gedmo/doctrine-extensions Version ^2.4 || ^3.1
nyholm/psr7 Version ^1.3
setono/bot-detection-bundle Version ^1.7
setono/client-id-bundle Version ^0.2
setono/client-id-contracts Version ^0.2
setono/consent-bundle Version ^0.1
setono/consent-contracts Version ^0.1.3
setono/doctrine-object-manager-trait Version ^1.0
setono/google-analytics-measurement-protocol Version ^0.4.3
setono/symfony-main-request-trait Version ^1.0
symfony/config Version ^4.4 || ^5.4 || ^6.0
symfony/console Version ^4.4 || ^5.4 || ^6.0
symfony/dependency-injection Version ^4.4 || ^5.4 || ^6.0
symfony/event-dispatcher Version ^4.4 || ^5.4 || ^6.0
symfony/http-client Version ^4.4 || ^5.4 || ^6.0
symfony/http-foundation Version ^4.4 || ^5.4 || ^6.0
symfony/http-kernel Version ^4.4 || ^5.4 || ^6.0
symfony/lock Version ^4.4 || ^5.4 || ^6.0
symfony/messenger Version ^4.4 || ^5.4 || ^6.0
symfony/uid Version ^5.4 || ^6.0
symfony/workflow Version ^4.4 || ^5.4 || ^6.0
webmozart/assert Version ^1.11