Haven’t seen a Google analytics plugin anywhere, so I created this simple plugin, which prints out the Google Analytics code needed to track website statistics.
Basically I was tired of hunting down for that short but complicated GA code on the web every time I needed to install the tracking script. Was also tired of always having to remember the Web property ID, and having to paste it at the right place in the GA code.
Usage:
{exp:google_analytics id="UA-9999999-1"}
or if you added your Web property ID in your config.php file as so:
$conf['google_analytics_id'] = "UA-9999999-1";
... you can simply type
{exp:google_analytics}
Parameters
id="UA-9999999-1"
The Google Analytics ID for your site*
* If you added your Web property ID in your config.php file, the id parameter is not needed and is ignored in the template.
code="urchin"
If set to “urchin”, the old Google Analytics urchin code will be loaded. If set to “ga” or “normal”, or if the parameter is absent, the standard Google Analytics code will be loaded.
Useful for quickly adding the GA code to specific templates.
Also useful with conditionals to turn off tracking for certain logged in members. For example, the following would turn off Google Analytics tracking when Super Admins are logged in:
{if logged_in && member_group != "1"}
{exp:google_analytics}
{/if}
