PHPackages                             hamaryuginh/google-analytics-bundle - 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. [API Development](/categories/api)
4. /
5. hamaryuginh/google-analytics-bundle

ActiveSymfony-bundle[API Development](/categories/api)

hamaryuginh/google-analytics-bundle
===================================

Symfony2 Google Analytics Bundle

v0.2(9y ago)42.7k1MITPHPPHP &gt;=5.4.0

Since Jun 24Pushed 9y ago2 watchersCompare

[ Source](https://github.com/hamaryuginh/google-analytics-bundle)[ Packagist](https://packagist.org/packages/hamaryuginh/google-analytics-bundle)[ Docs](http://hamaryuginh.github.io/google-analytics-bundle/)[ RSS](/packages/hamaryuginh-google-analytics-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

GoogleAnalyticsBundle
=====================

[](#googleanalyticsbundle)

*Work in progress*

This [Symfony](https://symfony.com/) bundle will simplify the management of interactions with google analytics.

Installation
============

[](#installation)

Install [composer](https://getcomposer.org/)

Add the following to your require block in composer.json config

```
"hamaryuginh/google-analytics-bundle": "dev-master"

```

Then, execute the following command in your symfony poject root

```
$ composer install

```

Configuration
=============

[](#configuration)

Register the bundle in `app/AppKernel.php`:

```
public function registerBundles()
{
    ...
    new Hamaryuginh\GoogleAnalyticsBundle\HamaryuginhGoogleAnalyticsBundle(),
    ...
}
```

Add to your `app/config/config.yml` the following:

```
hamaryuginh_google_analytics:
    account: UA-XXXXXX-Y   # Your GA account ID
    debug:   false         # [Facultative] set to true to activate debug mode
    enabled: false         # Enable or disable tracking
```

Add the following before `` tag:

```
{{ ga_initialize() }}
```

At the end of your document, before the `` tag, add:

```
{{ ga_start() }}
```

Install assets (from your symfony project root):

```
$ php app/console assets:install --symlink
```

Usage
=====

[](#usage)

Globally, you define a `data-ga-xxx` attribute on any tag and you give arguments as JSON string (ex: `data-ga-page="{'page':'/home'}"`)

**Page tracking**

Add `data-ga-page` attribute on `` tag or any other tag:

```

  ...

```

Or:

```

  ...

  ...

```

Or whatever you want...

> **Warning!** `data-ga-page` must be defined only **once** per document !

For further information, take a look at the [Page tracking](https://developers.google.com/analytics/devguides/collection/analyticsjs/pages) documentation.

**Custom dimentions and metrics**

Add `data-ga-dimension` attribute on any tag:

```

  ...

  ...

  ...

```

For further information, take a look at the [Custom dimensions and metrics](https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets) documentation.

**Event tracking (only "click" event at the moment)**

Add `data-ga-event` attribute on any tag:

```

  ...
  Home
  ...

  ...

```

For further information, take a look at the [Event tracking](https://developers.google.com/analytics/devguides/collection/analyticsjs/events) documentation.

**Social interactions (only homemade social buttons at the moment)**

Add `data-ga-social` attribute on any tag:

```

  ...

  ...

```

For further information, take a look at the [Social interactions](https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions) documentation.

**Last but not least**

Obviously, you can still use the **Google Analytics** library by the default way:

```

  ga('set', 'dimension1', 'toto');
  ...
  ga('send', 'event', ...);
  ...
  ga('send', 'pageview');

```

Ecommerce usage
===============

[](#ecommerce-usage)

**1. Start the ecommerce tracking**

Be sure to only declare this once and AFTER initializing the GA tracker (see Configuration)

```
{{ ga_ecommerce_initialize() }}
```

**2. Add a transaction**

A transaction is like a basket

```
{{ ga_ecommerce_addTransaction('transactionid',
                            'affiliation',
                            'totalAmount',
                            'shipping',
                            'taxRate') }}
```

**3.Add an item to the transaction**

An item is a product in your basket. Add as many items in your transaction as you want.

```
{{ ga_ecommerce_addItem('transactionId',
                        'productName',
                        'sku',
                        'category',
                        'price',
                        'quantity') }}
```

**4. Send the transaction to GA**

Call this after having added all the items to the transaction.

```
{{ ga_ecommerce_send() }}
```

**Have fun!**

Contributions
=============

[](#contributions)

Feel free to open an issue or add a pull request.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~259 days

Total

2

Last Release

3355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/684e3e6529333e853870f9053ac2b5c4608d08dad3aa44441bd5231161940bb4?d=identicon)[hamaryuginh](/maintainers/hamaryuginh)

---

Top Contributors

[![hamaryuginh](https://avatars.githubusercontent.com/u/2798525?v=4)](https://github.com/hamaryuginh "hamaryuginh (20 commits)")[![GWillmann](https://avatars.githubusercontent.com/u/5655900?v=4)](https://github.com/GWillmann "GWillmann (5 commits)")

---

Tags

symfony2 bundle google analytics ga

### Embed Badge

![Health badge](/badges/hamaryuginh-google-analytics-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hamaryuginh-google-analytics-bundle/health.svg)](https://phpackages.com/packages/hamaryuginh-google-analytics-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
