Download the PHP package calevans/staticforge-google-analytics without Composer

On this page you can find all versions of the php package calevans/staticforge-google-analytics. 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 staticforge-google-analytics

StaticForge GoogleAnalytics

A StaticForge feature package.

Copyright 2025, Cal Evans
License: MIT

Installation

Configuration

Add the following to your siteconfig.yaml:

And add your tracking ID to your .env file:

Set the ID in either .env or siteconfig.yaml, not both — see below.

Tracking ID

Both GA4 (G-XXXXXXXXXX) and Google Tag Manager (GTM-XXXXXXX) container IDs are accepted. The ID is resolved from two possible sources, in order:

  1. GOOGLE_ANALYTICS_ID in .env (trimmed, non-empty)
  2. google_analytics.tracking_id in siteconfig.yaml (trimmed, non-empty)

If neither source provides an ID, injection is skipped for the whole build and a warning is logged. If an ID is provided but does not match the expected G-/GTM- format, injection is also skipped and an error is logged — a malformed ID would otherwise produce a page that looks instrumented but silently collects nothing.

Kill switch

GOOGLE_ANALYTICS_ENABLED in .env can be set to false, 0, off, or no (case-insensitive) to force-disable injection regardless of what siteconfig.yaml says. This is a one-way switch: there is no GOOGLE_ANALYTICS_ENABLED=true that turns the feature on — it only suppresses. It exists so a non-production environment (e.g. a staging .env) can guarantee analytics never fires without having to also edit siteconfig.yaml. Any other value, including an empty string or the variable being absent entirely, leaves injection unaffected. That last part is deliberate: .env values are always strings, so a GOOGLE_ANALYTICS_ENABLED="" left behind by a copied .env.example must not silently switch analytics off in production.

Debug mode

Setting google_analytics.debug: true adds { 'debug_mode': true } to the gtag('config', ...) call, which enables Google Analytics DebugView.

Excluding pages

google_analytics.exclude is a list of glob patterns matched against each page's output path, relative to OUTPUT_DIR, with backslashes normalized to forward slashes. Matching uses fnmatch() without FNM_PATHNAME, so * crosses / — drafts/* excludes every page under drafts/, including drafts/2024/post.html, not just files directly inside drafts/. Matching is case-sensitive.


All versions of staticforge-google-analytics with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
eicc/staticforge Version ^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 calevans/staticforge-google-analytics contains the following files

Loading the files please wait ...