By endroid
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.
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(),
);
}
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 }
After installation and configuration, the tracker can be rendered using the following Twig syntax.
<html>
<head>
...
{{ google_analytics_tracker('default') }}
</head>
...
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.
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.