2017 © Pedro Peláez
 

library yii-ga

Google Analytics extension for the Yii framework

image

jalle19/yii-ga

Google Analytics extension for the Yii framework

  • Tuesday, June 3, 2014
  • by Jalle19
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,211 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

yii-ga

Google Analytics extension for the Yii framework. It supports general tracking as well as tracking e-commerce transactions., (*1)

See https://developers.google.com/analytics/devguides/ for general information about Google Analytics integration., (*2)

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:, (*3)

// 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)., (*4)

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):, (*5)

<?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, (*6)

Credits

Thanks to @crisu83 for giving me some pointers!, (*7)

The Versions

03/06 2014

dev-master

9999999-dev https://github.com/Jalle19/yii-ga

Google Analytics extension for the Yii framework

  Sources   Download

BSD-2-Clause

The Requires

 

analytics yii ga googleanalytics

03/06 2014

1.0.2

1.0.2.0 https://github.com/Jalle19/yii-ga

Google Analytics extension for the Yii framework

  Sources   Download

BSD-2-Clause

The Requires

 

analytics yii ga googleanalytics

14/05 2014

1.0.1

1.0.1.0 https://github.com/Jalle19/yii-ga

Google Analytics extension for the Yii framework

  Sources   Download

BSD-2-Clause

The Requires

 

analytics yii ga googleanalytics

09/07 2013

1.0.0

1.0.0.0 https://github.com/Jalle19/yii-ga

Google Analytics extension for the Yii framework

  Sources   Download

BSD-2-Clause

The Requires

 

analytics yii ga googleanalytics