strego / google-bundle
Bundle to use the Universal Analytics Google API
Installs: 43
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Type:symfony-bundle
Requires
- php: >=5.3.0
- symfony/symfony: >=2.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-11-05 07:31:29 UTC
README
This is based on the original AntiMattr/GoogleBundle. It is solely for Analytics using the Universal Analytics API
Installation
Application Kernel
Add GoogleBundle to the registerBundles()
method of your application kernel:
public function registerBundles()
{
return array(
new Strego\GoogleBundle\StregoGoogleBundle(),
);
}
Configuration
Google Analytics
Application config.yml
Enable loading of the Google Analytics service by adding the following to
the application's config.yml
file:
strego_google:
default_tracker: default
trackers:
default:
accountId: xXxxXx
cookieDomain: .example.com
Full Configugarion Reference
strego_google:
default_tracker: default
trackers:
default:
accountId: xXxxXx
cookieDomain: .example.com
allowHash: false
allowLinker: true
trackPageLoadTime: false
View
Include the Google Analytics Async template in the head
tag or just before the </body>
of your layout (The template will lazy load ga).
With twig:
{% include "StregoGoogleBundle:Analytics:async.html.twig" %}
Usage
Manually trigger an PageView
Just get the analytics service in your controller via:
$analytics = $this->get('strego_google');
// To add just a pageview:
$analytics->addPageView('/testPage');
//To add a Pageview with a specific title
$analytics->addPageView('/testPage2', 'testPage2Title);