PHPackages                             jalle19/yii-ga - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jalle19/yii-ga

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jalle19/yii-ga
==============

Google Analytics extension for the Yii framework

1.0.2(11y ago)21.2k3BSD-2-ClausePHPPHP &gt;=5.3.0

Since Jul 9Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Jalle19/yii-ga)[ Packagist](https://packagist.org/packages/jalle19/yii-ga)[ Docs](https://github.com/Jalle19/yii-ga)[ RSS](/packages/jalle19-yii-ga/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

yii-ga
======

[](#yii-ga)

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

See  for general information about Google Analytics integration.

Installation
------------

[](#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
-----

[](#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):

```
