tightenco/nova-google-analytics

Google Analytics integration with Nova

v0.1.7 2019-09-20 14:42 UTC

This package is auto-updated.

Last update: 2021-04-12 15:27:06 UTC


README

image

Google Analytics Integration with Nova

Latest Version on Packagist Total Downloads Build Status

JUST GETTING STARTED.

Plans:

  • Analytics tool
  • Individual cards for each of the useful analytics data points
  • Resource tools (e.g. analytics on each page)
  • Maybe actions for events?
  • Other great stuff I hope :)

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_VIEW_ID=

Usage

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

// in app/Providers/NovaServiceProvider.php

// ...

public function cards()
{
    return [
        // ...
        new \Tightenco\NovaGoogleAnalytics\PageViewsMetric,
        new \Tightenco\NovaGoogleAnalytics\VisitorsMetric,
        new \Tightenco\NovaGoogleAnalytics\MostVisitedPagesCard,
        new \Tightenco\NovaGoogleAnalytics\ReferrersList,
    ];
}

Features

View the Visitors and Pageview Metrics

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_VIEW_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 matt@tighten.co 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.