Download the PHP package freema/ga4-analytics-data-bundle without Composer

On this page you can find all versions of the php package freema/ga4-analytics-data-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ga4-analytics-data-bundle

Google Analytics 4 Data API Bundle for Symfony

A Symfony bundle for working with the Google Analytics 4 Data API. This bundle supports multiple Google Analytics properties, cache configuration, and provides a clean API to query analytics data.

Installation

Install the bundle using Composer:

The bundle uses Symfony Flex, so it will automatically:

Manual Installation (Without Flex)

If you're not using Symfony Flex, you need to:

  1. Register the bundle in your config/bundles.php:

  2. Create the configuration file at config/packages/ga4_analytics_data.yaml:

  3. Add the required environment variables to your .env file:

Requirements

Usage

Basic Usage

Using Multiple Clients

Custom Queries

Period Helper

The bundle includes a Period class to easily define date ranges:

Caching

The bundle provides flexible caching options:

Symfony Web Profiler Integration

The bundle includes a data collector for the Symfony Web Profiler that shows:

This can be disabled by setting profiler: false in the bundle config.

Getting Google Analytics 4 Credentials

Creating Service Account Credentials

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the "Google Analytics Data API" for your project
  4. Go to "APIs & Services" > "Credentials"
  5. Create a new "Service Account"
  6. Download the JSON key file for the service account
  7. In Google Analytics, go to Admin > Property > Property Access Management
  8. Add the service account email with "Viewer" permissions

Credentials File Format

The service account credentials file should be a JSON file with the following structure:

Security Best Practices

  1. Store credentials securely: Keep the JSON file in a secure location, outside of your web root
  2. Use environment variables: Reference the path to the credentials file using environment variables
  3. Restrict permissions: Set appropriate file permissions to limit access to the credentials file
  4. Environment-specific paths: Use different paths for different environments (dev, staging, prod)

Error Handling

The bundle validates the credentials file and provides clear error messages for common issues:

If you encounter credential errors, check:

  1. That the file exists at the specified path
  2. That the file has proper read permissions
  3. That the file contains valid JSON with all required fields
  4. That the service account has access to the Google Analytics property

License

This bundle is released under the MIT License. See the included LICENSE file.

Contributing

See CONTRIBUTING.md for information on how to contribute to this project.


All versions of ga4-analytics-data-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-bcmath Version *
ext-json Version *
symfony/http-kernel Version ^5.4|^6.4|^7.1
symfony/framework-bundle Version ^5.4|^6.4|^7.1
symfony/dependency-injection Version ^5.4|^6.4|^7.1
symfony/config Version ^5.4|^6.4|^7.1
google/analytics-data Version ^0.20.0
google/analytics-admin Version ^0.22.0
psr/log Version ^1.0|^2.0|^3.0
psr/cache Version ^1.0|^2.0|^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package freema/ga4-analytics-data-bundle contains the following files

Loading the files please wait ...