Overview

The neos/googleanalytics package connects to Google using service account credentials. These credentials are stored in a persistent cache using a filesystem backend by default. Since Beach instances use ephemeral storage, the credentials would be lost after each deployment if stored in the container's file system.

If the database is used instead, the credentials will survive deployments and your Google Analytics integration will continue to work.

Using a DB cache backend for the credentials

Configuring the package to use a database-backed cache in Beach is easy: all it takes is providing the necessary information in a file called Caches.yaml and deploy it as part of your Neos distribution.

In your Neos project, create a new file Caches.yaml in the global configuration directory of your project. We recommend putting the configuration into Configuration/Production/Caches.yaml. If you have a Caches.yaml file already, edit it instead.

Then copy and paste the following YAML configuration into your new file:

Neos_GoogleApiClient_Credentials:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    dataSourceName: 'mysql:host=%env:BEACH_DATABASE_HOST%;dbname=%env:BEACH_DATABASE_NAME%'
    username: '%env:BEACH_DATABASE_USERNAME%'
    password: '%env:BEACH_DATABASE_PASSWORD%'
    defaultLifetime: 0