bitmannl/codeigniter-piwik

本包最新版本(1.0.0)没有可用的许可证信息。

通过 Composer 安装 codeigniter-piwik (natec23)

1.0.0 2015-03-20 16:08 UTC

This package is not auto-updated.

Last update: 2024-09-18 08:17:56 UTC


README

CodeIgniter 库,用于从 Piwik 开源分析工具中检索统计信息。同时包含一个助手,用于根据 piwik 配置文件中定义的 piwik 设置生成 piwik 跟踪标签。

要求

  1. CodeIgniter 1.7.2 - 2.0-dev
  2. Piwik 安装
  3. 对于 GeoIP 功能:MaxMind GeoLiteCity

有帮助的链接

使用方法

// --- CONFIGURATION ( config/piwik.php ) ------------------------------------------ //

// Base URL to the Piwik Install
$config['piwik_url'] = 'http://stats.example.com';

// HTTPS Base URL to the Piwik Install (not required)
$config['piwik_url_ssl'] = 'https://stats.example.com';

// Piwik Site ID for the website you want to retrieve stats for
$config['site_id'] = 1;

// Piwik API token, you can find this on the API page by going to the API link from the Piwik Dashboard
$config['token'] = '0b3b2sdgsd7e82385avdfgde44dsfgd5g';

// To turn geoip on, you will need to set to TRUE  and GeoLiteCity.dat will need to be in helpers/geoip
$config['geoip_on'] = FALSE;

// Controls whether piwik_tag helper function outputs tracking tag (for production, set to TRUE)
$config['tag_on'] = FALSE;


// --- LIBRARY Usage --------------------------------------------------------------- //

// Load Libary
$this->load->library('piwik');

// Get Actions
// Get last 10 days
$data['actions'] = $this->piwik->actions('day', 10);
// Get last 6 months
$data['actions'] = $this->piwik->actions('month', 6);

// Get Last 10 Visitors
$data['visitors'] = $this->piwik->last_visits();

// Get Last 10 Visitors Formatted (tries to eliminate need from parsing whats returned from the last_visits function)
$data['visitors'] = $this->piwik->last_visits_parsed();

// If GeoIP enabled, and you want to get geoip information, pass it an IP Address
$geoip = $this->piwik->get_geoip('127.0.0.1');


// --- HELPER Usage ---------------------------------------------------------------- //

// Load the helper to use to generate tracking tag
$this->load->helper('piwik');

// Call the helper function before the closing body tag in your view
...
<?php echo piwik_tag(); ?>
</body>
</html>

待办事项

  • 添加更多库函数以支持其他 API 方法
  • 完成所有现有库函数的文档,并添加用户指南
  • 改进某些函数返回数据的方式
  • 将 GeoIP 集成到 Google Maps API 中,以构建访客地图