承接 bolstad/analytrix 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bolstad/analytrix

最新稳定版本:0.4.2

Composer 安装命令:

composer require bolstad/analytrix

包简介

jump start kit for Google Analytics-based web apps

README 文档

README

A PHP jump start kit for Google Analytics-based web apps. Setup your GA-API settings in your enviroments ettings (or a .env file) and you a are ready to go.

Rest on the shoulder of the gigants: timgws/google-analytics-api and vlucas/phpdotenv

Code Example

date_default_timezone_set( 'Europe/Stockholm' );
session_start();

include 'vendor/autoload.php';

$ding = new Analytrix\Basic(  new \Dotenv\Dotenv(__DIR__), new \timgws\GoogleAnalytics\API, new Analytrix\SessionStorageFile);

$ding->storage->setBucket('bucket name');
$ACCOUNT_ID = 'ga:123456-1';
echo "ACCOUNT_ID: $ACCOUNT_ID\n";

$ding->LoginText = 'Please login here';
$ding->DieOnNoSession = true;

$ding->run();

$auth = $ding->storage->get('auth');

if ( $auth = $ding->storage->get('auth') ) {

    echo "Yes, session is set\n";

    print_r( $auth );

    $accessToken = $auth['access_token'];
    $tokenExpires = $auth['expires_in'];

    $ding->ga->setAccessToken( $accessToken );
    $ding->ga->setAccountId( $ACCOUNT_ID );

    // Set the default params. For example the start/end dates and max-results
    $defaults = array(
        'start-date' => date( 'Y-m-d', strtotime( '-1 month' ) ),
        'end-date' => date( 'Y-m-d' ),
    );
    $ding->ga->setDefaultQueryParams( $defaults );

    // Example1: Get visits by date
    $params = array(
        'metrics' => 'ga:visits',
        'dimensions' => 'ga:date',
    );
    $visits = $ding->ga->query( $params );

    echo '<pre>';
    print_r( $visits );
    echo '</pre>';
    die;
}

Installation

  • Install this library via composer: composer require 'bolstad/analytrix:dev-master'

  • Create a Project in the Google APIs Console: https://code.google.com/apis/console/

  • Enable the Analytics API under Services

  • Under API Access: Create an Oauth 2.0 Client-ID

  • Give a Product-Name, choose Web Application or Service Account depending on your needs

  • Web Application: Set a redirect-uri in the project which points to your apps url

  • Config your ENV with the aplication API vars with these names: CLIENT_ID, CLIENT_SECRET & REDIRECT_URI

API Reference

Depending on the size of the project, if it is small and simple enough the reference docs can be added to the README. For medium size to larger projects it is important to at least provide a link to where the API reference docs live.

Describe and show how to run the tests with code examples.

Contributors

Christian Bolstad christian@bolstad.se

License

MIT

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固