jalle19/yii-ga 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jalle19/yii-ga

Composer 安装命令:

composer require jalle19/yii-ga

包简介

Google Analytics extension for the Yii framework

README 文档

README

Google Analytics extension for the Yii framework. It supports general tracking as well as tracking e-commerce transactions.

See https://developers.google.com/analytics/devguides/ for general information about Google Analytics integration.

Installation

Install the application using Composer and make sure you've included Composer's autoloader in your bootstrap file. After that you will need to add the following to your application configuration:

// change this path if necessary
Yii::setPathOfAlias('yiiga', realpath(__DIR__.'/../../vendor/jalle19/yii-ga/src/yiiga'));
...
return array(
	...
	'components'=>array(
		...
		'ga'=>array(
			'class'=>'yiiga\components\GoogleAnalytics',
			'accountId'=>'UA-XXXXXXX-X',
			'cookieDomain'=>'www.example.com', // optional
			'currency'=>'euro', // only needed if you're going to use e-commerce transactions
		),
	),
),

Usage

To register basic tracking support, add Yii::app()->ga->registerTracking(); to your main layout file (assuming you want to track the whole site).

To register e-commerce transactions, adapt the following snippet to your needs (see the class files for which properties are available for transactions and transaction items):

<?php

/* @var $order Order */

// Create a new transaction
$transaction = new yiiga\models\Transaction();
$transaction->orderId = $order->id;
$transaction->city = $order->city;
$transaction->country = $order->country;
$transaction->total = $order->total;
$transaction->tax = $order->tax;

// Add the order items to the transaction
foreach ($order->items as $orderItem)
{
	$item = new yiiga\models\TransactionItem();
	$item->sku = $orderItem->sku;
	$item->name = $orderItem->name;
	$item->price = ($orderItem->price + $orderItem->tax);
	$item->quantity = $orderItem->quantity;

	$transaction->addItem($item);
}

// Register the transaction
Yii::app()->ga->addTransaction($transaction);

License

This application is licensed under the New BSD License

Credits

Thanks to @crisu83 for giving me some pointers!

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2013-07-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固