endroid/google-analytics-bundle

Endroid Google Analytics for Symfony

Installs: 4 131

Dependents: 1

Stars: 4

Watchers: 1

Forks: 1

Language: PHP

1.0.12 2015-07-04 18:17 UTC

README

By endroid

Build Status Latest Stable Version Total Downloads

This bundle integrates Google Analytics in your project. It allows you to create one or multiple tracking codes and provides easy definition of tracking script in you templates.

knpbundles.com

Installation

Use Composer to install the bundle.

$ composer require endroid/google-analytics-bundle

Then enable the bundle via the kernel.

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Endroid\Bundle\GoogleAnalyticsBundle\EndroidGoogleAnalyticsBundle(),
    );
}

Configuration

config.yml

Multiple trackers can be defined via the configuration. A tracker can either be created using the short syntax or using the long syntax (in case you want to change one of the optional parameters).

endroid_google_analytics:
    trackers:
        default: UA-XXXX-Y
        extra: { property_id: UA-XXXX-Z, require_display_features: true }

Usage

After installation and configuration, the tracker can be rendered using the following Twig syntax. Multiple trackers can be included on a single page.

<head>

    ...

    {{ google_analytics_tracker('default') }}

    {{ google_analytics_tracker('extra') }}

</head>

Versioning

Semantic versioning (semver) is applied as much as possible.

License

This bundle is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.