Giter Club home page Giter Club logo

nova-google-analytics's Introduction

image

Google Analytics Integration with Nova

Latest Version on Packagist Total Downloads Build Status

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require tightenco/nova-google-analytics

For now, follow the directions on Spatie's Laravel Google Analytics package for getting your credentials, then put them here:

yourapp/storage/app/analytics/service-account-credentials.json

Also add this to the .env for your Nova app:

ANALYTICS_PROPERTY_ID=

Upgrading to 4.0

Version 4.0 uses the new Google Analytics 4 Data API.

  • Upgrades spatie/laravel-analytics to v5.2
    • Drops support for PHP 8.0
    • Drops support for Laravel 9
  • Removes FourteenDayActiveUsersMetric metric which is not available in GA4

The required environment variable ANALYTICS_VIEW_ID has been renamed to ANALYTICS_PROPERTY_ID to match Google's usage.

Usage

You must register the cards you want to display with Nova. This is typically done in the cards method of the Main dashboard.

// in app/Nova/Dashboards/Main.php

// ...

public function cards()
{
    return [
        // ...
        new \Tightenco\NovaGoogleAnalytics\PageViewsMetric,
        new \Tightenco\NovaGoogleAnalytics\VisitorsMetric,
        new \Tightenco\NovaGoogleAnalytics\MostVisitedPagesCard,
        new \Tightenco\NovaGoogleAnalytics\ReferrersList,
        new \Tightenco\NovaGoogleAnalytics\OneDayActiveUsersMetric,
        new \Tightenco\NovaGoogleAnalytics\SevenDayActiveUsersMetric,
        new \Tightenco\NovaGoogleAnalytics\TwentyEightDayActiveUsersMetric,
        new \Tightenco\NovaGoogleAnalytics\SessionsMetric,
        new \Tightenco\NovaGoogleAnalytics\SessionDurationMetric,
        new \Tightenco\NovaGoogleAnalytics\SessionsByDeviceMetric,
        new \Tightenco\NovaGoogleAnalytics\SessionsByCountryMetric,
    ];
}

Register the tool with Nova in the tools method of your NovaServiceProvider:

// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
    return [
        new Tightenco\NovaGoogleAnalytics\Tool(),
    ];
}

Features

View the Visitors and Pageview Metrics

image

View the Active Users Metrics

image

View the Sessions and Avg. Session Duration Metrics

image

View the Devices and Country Metrics by Session

image

View the lists of Most Visited Pages and Referrers

image

Testing

First, copy your .env.example file to a new file called .env.testing:

cp .env.example .env.testing

Make sure, in that file, to define the following variables to run all tests:

ANALYTICS_PROPERTY_ID
ANALYTICS_PROJECT_ID
ANALYTICS_PRIVATE_KEY_ID
ANALYTICS_PRIVATE_KEY
ANALYTICS_CLIENT_EMAIL_KEY
ANALYTICS_CLIENT_ID
ANALYTICS_CLIENT_CERT_URL

Add the .env.testing file in .gitignore so you can safely use the same analytics view ID to run the tests that you use for the card.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Support us

Tighten is a web development firm that works in Laravel, Vue, and React. You can learn more about us on our web site

License

The MIT License (MIT). Please see License File for more information.

nova-google-analytics's People

Contributors

dmyers avatar driftingly avatar faxblaster avatar jasonlbeggs avatar krievley avatar lalarukh1 avatar m-a-k-o avatar mattstauffer avatar mbardelmeijer avatar tonysm avatar wilburpowery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nova-google-analytics's Issues

Dropdown label not displayed correctly

Nova: v2.0.3
nova-google-analytics: v0.1.6

Hi, I have updated my nova-google-analytics to the latest version 0.1.6. After update it, the dropdown label no longer appear. Below is the screenshot for your reference. Any thoughts? thanks

image

Not working with GA 4

dev does not try this package, it is not working with GA 4 now

it took many hours to fix problem but not success

"{
"error": {
"code": 403,
"message": "User does not have sufficient permissions for this profile.",
"errors": [
{
"message": "User does not have sufficient permissions for this profile.",
"domain": "global",
"reason": "insufficientPermissions"
}
]
}
}
"
after review Issues, then i confirm that Ga4 is not supported now March 2024.

the author, please mark project abandoned so that does not take other dev's time

thank you

Statistics reporting the wrong increase/decrease percentage

Hi,

I just installed your package, and it is reporting page views and visitors to date correctly. However, the reporting of the increase/decrease percentages is wildly off. In my case it reports about a 500% increase of both metrics, them actually going down 10% this year. Any idea why this is? It does not matter which date range I select, all of them under or over report the change significantly.

image

Range selection

Hi! When are you finishing the range selection? Would nice to see more cards. Cheers.

Does the Referrers List card work?

I noticed that the class the card extends had the wrong casing and made PR #16 for it.

I then still had an issue I haven't yet solved with the card being blank when I have referrals in Google Analytics so I don't think it's the data source.

In my cards array:

use Tightenco\NovaGoogleAnalytics\PageViewsMetric as AnalyticsPageViews;
use Tightenco\NovaGoogleAnalytics\VisitorsMetric as AnalyticsVisitors;
use Tightenco\NovaGoogleAnalytics\MostVisitedPagesCard as AnalyticsTopPages;
use Tightenco\NovaGoogleAnalytics\ReferrersList as AnalyticsTopReferrers;

    protected function cards()
    {
        return [
            new AnalyticsPageViews,
            new AnalyticsVisitors,
            new AnalyticsTopPages,
            new AnalyticsTopReferrers,
            new ProductClicks,
        ];
    }

Laravel 9 packages conflict

Problem 1
- Root composer.json requires raiym/instagram-php-scraper ^0.12 -> satisfiable by raiym/instagram-php-scraper[v0.12.0, ..., v0.12.4].
- tightenco/nova-google-analytics v2.0.0 requires spatie/laravel-analytics ^4.1 -> satisfiable by spatie/laravel-analytics[4.1.0].
- Root composer.json requires tightenco/nova-google-analytics ^2.0.0 -> satisfiable by tightenco/nova-google-analytics[v2.0.0].
- Root composer.json requires spatie/laravel-sitemap ^6.1.0 -> satisfiable by spatie/laravel-sitemap[6.1.0].
- spatie/laravel-analytics 4.1.0 requires laravel/framework ^9.0 -> satisfiable by laravel/framework[v9.1.0, 9.x-dev].
- Only one of these can be installed: illuminate/collections[dev-master, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev], laravel/framework[v9.1.0, 9.x-dev]. laravel/framework replaces illuminate/collections and thus cannot coexist with it.
- Conclusion: install illuminate/collections v8.83.1 (conflict analysis result)

MostVisitedPagesCard and ReferrersList throws js error

Hello,
when I use MostVisitedPagesCard or ReferrersList dashboard cards. On load dashboard js throws this error:

nova-google-analytics-card:727 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_c')
    at Proxy.render (nova-google-analytics-card:727:22)
    at renderComponentRoot (runtime-core.esm-bundler.js?d2dd:893:1)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?d2dd:5030:1)
    at ReactiveEffect.run (reactivity.esm-bundler.js?89dc:167:1)
    at setupRenderEffect (runtime-core.esm-bundler.js?d2dd:5156:1)
    at mountComponent (runtime-core.esm-bundler.js?d2dd:4939:1)
    at processComponent (runtime-core.esm-bundler.js?d2dd:4897:1)
    at patch (runtime-core.esm-bundler.js?d2dd:4489:1)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?d2dd:5037:1)
    at ReactiveEffect.run (reactivity.esm-bundler.js?89dc:167:1)

Can anyone help me please? :)

Does it support GA4 spatie package?

It's not working with latest "spatie/laravel-analytics": "^5.0" version.

Tasks

No tasks being tracked yet.

exception with new analytics - without data

Trying to access array offset on value of type null {"userId":1,"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /.../vendor/tightenco/nova-google-analytics/src/PageViewsMetric.php:42)

'previous' => $analyticsData->first()['pageViews'],
'result' => $analyticsData->last()['pageViews'],

[Request]: ability to see analytics for multiple domains

Hello @mattstauffer ,

Need your opinion on this.
Does it seem OK to have support for analytics data for multiple domains on Nova Dashboard.

Its very specific use case, i doubt it if even spatie's, laravel-analytics would be able to support it. Since its not in that package's scope.

Since its very specific, I guess creating a new repo with this support would be needed, will require work like having mutliple ANALYTICS_VIEW_ID and multiple credential.json to be stored.

Any thoughts?

Laravel 9 or PHP 8 support

First, thank you for sharing this great package!

Currently I am checking if the usual packages I include in new projects are compatible with Laravel 9. And I encountered this error when installing your package:

  Problem 1
    - tightenco/nova-google-analytics[v1.0.0, ..., v1.0.1] require spatie/laravel-analytics ^3.6 -> satisfiable by spatie/laravel-analytics[3.6.0, ..., 3.11.0].
    - spatie/laravel-analytics[3.6.0, ..., 3.6.x-dev] require php ^7.0 -> your php version (8.0.10) does not satisfy that requirement.
    - spatie/laravel-analytics[3.7.0, ..., 3.10.1] require php ^7.2 -> your php version (8.0.10) does not satisfy that requirement.
    - spatie/laravel-analytics[3.10.2, ..., 3.11.0] require laravel/framework ^6.0|^7.0|^8.0 -> found laravel/framework[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but it conflicts with your root composer.json require (^9.0).
    - Root composer.json requires tightenco/nova-google-analytics ^1.0 -> satisfiable by tightenco/nova-google-analytics[v1.0.0, v1.0.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Steps to replicate:

  1. laravel new l9 and install Nova
  2. composer require tightenco/nova-google-analytics

The same error occurs even when I include --with-all-dependencies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.