Skip to content
This repository has been archived by the owner on Dec 31, 2017. It is now read-only.

Google Analytics Bundle for use in Symfony

License

Notifications You must be signed in to change notification settings

abandroid/google-analytics-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Analytics Bundle

By endroid

Latest Stable Version Build Status Total Downloads Monthly Downloads License

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
        another: { property_id: UA-XXXX-Z, require_display_features: true }
        

Usage

After installation and configuration, the tracker can be rendered using the following Twig syntax.

<html>
    <head>
        ...
        {{ google_analytics_tracker('default') }}
    </head>
    ...

Versioning

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

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.