Git Product home page Git Product logo

google-analytics-rt's Introduction

google-analytics-rt

Google Analytics Realtime thin client.

Author

Piotr 'Athlan' Pelczar

Created with โค for majsterkowo.pl to support the Analogue Counter of Active Users on the website.

Installation

  1. Clone repository.
  2. composer install
  3. Go to configuration section.
  4. (optional) Upload to the server where you want to host the script.
  5. Make /var/cache writable for web server process (chmod 777 or proper write access)

Configuration

Create Google API Console application

  1. Create Project in Google Console (skip if you have one) and enable Google Analytics API. (link to the wizard)
  2. Create the Service Account and select the Project when prompted. (link to the wizard)
    • Type the name of the account and select Furnish a new private key.
    • Download the .json credentials file. Remember the client email like [email protected]

Configure Google Analytics account

  1. Login to the Google Analytics
    • Go to the Administration and add the new read-only user which email is as the Service Account email you just created (email from step 2).
    • Go to the your webpage administration, and copy the View ID from View Settings. Write it down.

Configure the script

  1. Copy the /config/config.php.diff to the /config/config.php
    • Copy the downloaded .json credentials file to the /config/credentials and point this file in config.php.
  2. Your service is configured. You can access the stats by invoking address:
    http://localhost/your-path-of-this-project/rt-visitors.php?profileId=XYZ`
    
    Where profileId is your View ID from Google Analytics.

Additional configuration

Caching

In configuration file you can configure caching:

  • Change TTL of cache (0 to disable).
  • Change cache driver (default is Filesystem) options like a directory to store cache.
  • Change cache driver to another one (list of drivers).

Known issues

  1. cURL error 60: SSL certificate problem: unable to get local issuer certificate

    You are not accepting the Google certificate.

    Possible solutions:

    • Update your certificates on the on the operating system.
    • Override your curl.cainfo property on the runtime or in php.ini file and point to the downloaded cacert.pem.
    • Just uncomment cacert settings in the config file and. Point to the downloaded cacert.pem file.This file is bundled in /config/cacert.pem.

    Read more: googleapis/google-api-php-client#1011

google-analytics-rt's People

Contributors

athlan avatar

Watchers

 avatar  avatar

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.