Easily add Google Analytics to your symfony project.
MIT License
= sfGoogleAnalyticsPlugin plugin =
Easily add [http://www.google.com/analytics Google Analytics] tracking code to your presentation layer.
''This documentation is a work in progress. Thank you for your patience.''
== Installation ==
=== 1. Install ===
You can install using the plugin-install
task:
{{{ php symfony plugin-install sfGoogleAnalyticsPlugin }}}
You can also pull the code directly from the [http://svn.symfony-project.org/plugins/sfGoogleAnalyticsPlugin/trunk Subversion repository] using a svn checkout
or the svn:externals
property on your project's /plugins
directory.
Once the plugin code is accessible to your project, you need to add the sfGoogleAnalyticsFilter
to your filter chain:
{{{ #!yaml rendering: ~ security: ~
sf_google_analytics_plugin: class: sfGoogleAnalyticsFilter
cache: ~ common: ~ execution: ~ }}}
''NOTE: This is the symfony 1.1 filters.yml
file. The equivalent symfony 1.0 file looks slightly different.''
=== 2. Configure ===
Basic configuration is done in your application's app.yml
file:
{{{ #!yaml all: sf_google_analytics_plugin: enabled: true profile_id: XX-XXXXX-X tracker: google }}}
You'll have to copy the profile_id
value out of the tracking code Google supplies for your site profile. This value typically starts with the letter U and ends with a single digit.
This plugin defaults to using the older urchin
tracker. To take advantage of the latest featureset of Google Analytics, change the tracker
value to google
for the older snippet or asynchronous
for the more performant one. This will insert the new ga.js
tracking code into your project.
== Advanced Usage ==
This plugin provides much more functionality than a simple insert of your tracking code. Here are some highlights:
=== How do I customize the name a page is tracked as? ===
If you would like to track a certain page as something other than what appears in the browser address bar, you can do so by modifying the page_name
parameter in module.yml
:
{{{ #!yaml all: myAction: sf_google_analytics_plugin: params: page_name: something_else }}}
For finer control over when the alternate page name is used, you can access the tracker object directly in your action. This also exposes additional funcionality.
==== Option: use_flash
====
For example, if you want to track a successful form submission for a form that redirects to the same page on success and on error:
{{{ #!php