Download the PHP package artisanpack-ui/analytics-google without Composer

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

ArtisanPack UI Analytics Google

Google Analytics 4 (GA4) integration for Laravel applications.

The package ships two independent surfaces that you can adopt separately:

Surface What it does Requires the artisanpack-ui/google base package?
Client-side tracking Emits the standard gtag.js snippet on your pages. No
Server-side reporting Queries the GA4 Data API for sessions, users, top pages, top events. Yes (for the OAuth token)

If you only need tracking, install this package alone. If you need dashboards, add the base too. The package boots either way — the reporting classes gracefully throw a well-typed BaseNotInstalledException when the base is missing, and reporting components render an "install the base" prompt instead of blowing up.

When installed alongside the artisanpack-ui/analytics parent, this package registers itself as the google-ga4 provider so client-side tracking runs through the parent's consent gate rather than firing unconditionally.

Install matrix

Pick the row that matches what you want to do:

Goal artisanpack-ui/analytics-google artisanpack-ui/google artisanpack-ui/analytics Livewire / React / Vue
Emit the gtag snippet from Blade
Emit the gtag snippet from React or Vue React or Vue
Route gtag through the analytics parent's consent gate
Query the GA4 Data API from your own code
Render the GA overview component Livewire, React, or Vue
Render the Top pages + top events component Livewire, React, or Vue
Drop the two components into the CMS framework admin dashboard artisanpack-ui/cms-framework + Livewire

Installation

For server-side reporting, also install the base package:

The service provider and AnalyticsGoogle facade are auto-discovered.

Publish the config:

Set the environment variables you need — measurement ID for tracking, property ID for reporting:

To forward the analytics parent's page views and events to GA4 from the server (since 1.1.0), add a Measurement Protocol API secret:

Variable Description
GA4_API_SECRET Measurement Protocol API secret (GA4 → Admin → Data Streams → Measurement Protocol API secrets). Forwarding stays off until this and GA4_MEASUREMENT_ID are both set.
GA4_SERVER_SIDE_TRACKING Turns server-side forwarding off independently of the secret. Defaults to true.
GA4_PAGE_LOCATION_BASE Base URL used to build the absolute page_location GA4 expects. Defaults to app.url.
GA4_MEASUREMENT_PROTOCOL_DEBUG Sends hits to GA4's validation endpoint and logs the validation messages it returns. Defaults to false.

Read docs/analytics-parent-integration.md before enabling this — it covers the caveats around double-counting against client-side gtag.js, attribution, and session boundaries.

Client-side tracking

Blade

Drop the @ga4Snippet directive into your layout <head>:

The directive emits nothing when analytics-google.tracking.measurement_id is empty, so it is safe to leave in a shared layout across environments.

React

Vue

By default the snippet defers page_view events until the analytics parent's consent banner grants the analytics category — configurable via analytics-google.tracking.respect_consent. When the parent is not installed, tracking fires immediately since there is no consent gate to defer to.

Server-side reporting

Reporting requires the base package and a connected Google account for the current user. Under the hood the Ga4DataClient pulls an OAuth token from the base's TokenManager and POSTs against the GA4 Data API's runReport endpoint.

Ga4DataClient — raw queries

GA overview component

Four headline metrics — sessions, users, page views, average engagement time — plus a daily trend chart for a configurable date range.

Livewire:

React and Vue — publish the component sources, then point them at the built-in HTTP endpoint at /analytics-google/overview:

Top pages and events component

Top pages (by views) and top events (by count) for a configurable date range.

Livewire:

React and Vue — the endpoint lives at /analytics-google/top-content:

CMS framework admin widgets

When artisanpack-ui/cms-framework is installed, this package automatically registers both components as dashboard widgets:

Both are guarded behind the view_analytics capability. See the CMS framework's admin widgets documentation for how end users add them to their dashboard.

Configuration reference

See config/analytics-google.php. Highlights:

Graceful degradation

The package is deliberately safe to install without the base:

Contributing

Please read through the contributing guidelines to learn more about how you can contribute to this project.

License

ArtisanPack UI Analytics Google is open-source software licensed under the MIT license.


All versions of analytics-google with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
artisanpack-ui/core Version ^1.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 artisanpack-ui/analytics-google contains the following files

Loading the files please wait ...