Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Analytics Laravel Package

spatie/laravel-analytics

Laravel package to retrieve Google Analytics data with a simple API. Fetch most visited pages, visitors and page views for a given period, returning Laravel Collections. Quick to install, configurable, and works nicely in dashboards and reports.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Data-Driven Product Decisions: Enables PMs to integrate real-time Google Analytics (GA4) data directly into Laravel applications, supporting A/B testing, feature adoption analysis, and user behavior insights without relying on manual exports or third-party dashboards.
  • Roadmap Prioritization: Facilitates data-backed prioritization by providing granular metrics (e.g., top referrers, user types, device breakdowns) to validate hypotheses or measure impact of product changes.
  • Build vs. Buy: Avoids reinventing the wheel by leveraging a battle-tested, MIT-licensed package (3.2K+ stars) instead of building custom API integrations for GA4.
  • Use Cases:
    • Growth Metrics: Track conversions, bounce rates, and session duration for marketing campaigns.
    • Feature Analytics: Monitor engagement for new features (e.g., fetchMostVisitedPages for content performance).
    • Technical Insights: Identify top browsers/OSes to guide platform compatibility decisions.
    • Internal Tools: Power admin dashboards (e.g., fetchVisitorsAndPageViewsByDate) for stakeholders.

When to Consider This Package

  • Adopt if:

    • Your Laravel app needs direct GA4 integration without UI dependencies (e.g., embedding Google’s dashboard).
    • You require programmatic access to metrics for automated workflows (e.g., triggering alerts via fetchTotalVisitorsAndPageViews).
    • Your team lacks resources to maintain a custom GA4 API client or prefers open-source solutions.
    • You’re using GA4 (not Universal Analytics) and need to avoid deprecated APIs.
  • Look Elsewhere if:

    • You need real-time streaming (this package uses batch requests with caching).
    • Your stack isn’t Laravel/PHP (e.g., Node.js, Python).
    • You require advanced visualization (consider pairing with a frontend library like Chart.js).
    • You’re already using a managed analytics platform (e.g., Mixpanel, Amplitude) with built-in Laravel SDKs.
    • Compliance requires on-premise data processing (this uses Google’s API).

How to Pitch It (Stakeholders)

Executives:

"This package lets us tap into Google Analytics data directly within our Laravel backend—no more manual exports or third-party tools. For example, we can automatically track feature adoption (e.g., ‘How many users visited the new checkout flow?’) or identify traffic spikes from marketing campaigns. It’s secure (MIT-licensed, service-account based), scalable (handles large datasets via caching), and integrates seamlessly with our existing stack. The cost? Zero—just a one-time setup for Google API credentials. ROI? Faster, data-driven decisions without engineering overhead."

Engineering:

"Spatie’s laravel-analytics abstracts the complexity of Google’s Data API v1. We get a clean facade (Analytics::fetchVisitorsAndPageViews()) with built-in caching, testing support (Analytics::fake()), and Laravel’s Collections for easy manipulation. It’s lightweight (~50KB), well-documented, and actively maintained. For custom queries, the get() method lets us leverage GA4’s full API schema—no need to rewrite the wheel. Setup is straightforward: drop in a JSON credential file and configure the property ID."

Data/Analytics Teams:

"This gives us programmatic access to GA4 metrics without API rate limits or UI constraints. Need to compare user behavior across regions? fetchTopCountries(). Want to filter events (e.g., ‘Show me all sessions with >3 pageviews’)? The FilterExpression system handles it. Plus, the package’s caching (configurable) reduces API calls, cutting costs. We can even mock responses in tests—great for CI/CD pipelines."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport