.. include:: ../../Includes.txt .. _configuration-howto: ====== How-To ====== Target group: **Developers, Integrators** .. _howto-trackingobjects: TrackingObjects =============== .. _what-are-trackingobjects: What are TrackingObjects? ------------------------- A TrackingObject is an array which includes one or more tracking items (usually cookies). For example, the TrackingObject `GoogleAnalytics` contains five cookies which are used by this service. They are listed inside the `show` array. Depending on the purpose a TrackingObject has, you need to inject HTML code after the user has given his consent (see :ref:`next section `). .. _load-tracking-code-after-consent: How to load tracking code only after user consent? -------------------------------------------------- A web analytics service like Matomo or Google Analytics **needs the user's active consent** before the website starts with tracking. Therefore, you'll need to ensure that the tracking code is not executed automatically at page load. You need to remove all existing tracking codes from your website and let Cookieman manage them. Cookieman will inject the tracking codes after user consent with the :ref:`inject ` configuration. **Example:** .. code-block:: typoscript plugin.tx_cookieman.settings.trackingObjects { Matomo { inject = TEXT inject { insertData = 1 value = ( ) } } } .. _add-preconfigured-trackingobject: Adding a preconfigured TrackingObject ------------------------------------- Cookieman already provides some preconfigured TrackingObjects. You can add selected TrackingObjects with two (or three) steps in TypoScript: 1. Import the provided definitions. 2. Add the key (name) of the TrackingObject. .. code-block:: typoscript # 1. Include provided definitions of TrackingObjects: @import 'EXT:cookieman/Configuration/TypoScript/TrackingObjects/*.typoscript' # 2. Add the TrackingObject key to a group: plugin.tx_cookieman.settings.groups { mandatory { trackingObjects { 10 = fe_typo_user } } } 3. If a TrackingObject needs to inject HTML code, you'll have to add this in a third step: .. code-block:: typoscript # 1. Include provided definitions of TrackingObjects: @import 'EXT:cookieman/Configuration/TypoScript/TrackingObjects/*.typoscript' # 2. Add the TrackingObject key to a group (see below how to configure a new group): plugin.tx_cookieman.settings.groups { analytics { trackingObjects { 10 = GoogleAnalytics } } } # 3. Add the tracking code to the TrackingObject: plugin.tx_cookieman.settings.trackingObjects { GoogleAnalytics { inject { insertData = 1 value = ( ) } } } .. attention:: If your website sets the HTTP header `Content-Security-Policy`, you'll need to use ) } } } .. tip:: Read more about the Content Security Policy on the `Mozilla Developer Network `__. .. _extension-cookie-settings: Configuration of the cookie used by the extension itself -------------------------------------------------------- There are a few TypoScript constants to configure the cookie which is required by the exension (see :ref:`typoscript-constants`). .. code-block:: typoscript plugin.tx_cookieman { settings { cookie { # cookie expire time in days (default: 365) cookieLifetimeDays = # domain without protocol like www.example.com, .example.com (default: Typo3 site name) domain = # sameSite Options: Lax, Strict or None (default: Strict) sameSite = # send the cookie via https only (default: on). Cookieman sets it only on https pages. secure = } } } .. note:: Before cookieman 5.0.0 the default for ``sameSite`` was ``Lax``. Set ``sameSite = Lax`` to keep that behaviour. The `SameSite attribute on the Mozilla Developer Network `__ explains what the values do. .. note:: ``secure`` is on. It is safe to leave it on, also for an http website: cookieman sets the attribute only when the page is served via https. The `Secure attribute on the Mozilla Developer Network `__ explains what it does. Set ``secure = 0`` only if you have http/https subdomains that must be covered by the cookie (see the tip on ``domain`` below). This is the only reason to switch it off. Browsers also discard a cookie with ``sameSite = None`` if it is not ``secure``. .. tip:: If you have multiple TYPO3 sites running on one instance with multiple subdomains you propably do not want to have multiple cookieman cookies. This would also mean that the cookieman banner is displayed on both domains and that every website user has to configure it for every subdomain again. To avoid this just set the domain setting to the domain with a starting dot. .. code-block:: typoscript plugin.tx_cookieman.settings.cookie.domain = .example.com .. _show-the-popup-again: Show the consent popup again after a configuration change --------------------------------------------------------- A user who gave consent does not see the popup again. If you add a tracking object or change your groups, that user keeps the old consent and does not see the new configuration. Change :ref:`consentConfigurationVersion` every time you change your cookie configuration. The default is ``1``, so your first change sets it to ``2``: .. code-block:: typoscript plugin.tx_cookieman.settings.consentConfigurationVersion = 2 Cookieman writes the version into the consent cookie. If the version in the cookie of a user is not the same as the configured one, cookieman shows the popup again. The selections of the user stay in the checkboxes, so they only must confirm them. You can use any value, for example a date or the number of your release. .. important:: Until the user saves again, the old consent does not count: cookieman injects no tracking objects. This makes sure that a new tracking object does not start before the user consented to it. .. note:: Consent that cookieman before 5.0.0 saved holds no version. Cookieman adds the current version to such a cookie without a change for the user ("silent upgrade"). Nobody is asked again because of the upgrade to 5.0.0. Only your next change of the version shows the popup again.