ExpressionEngine addons

Google Analytics

Description

Adds Google Analytics tracking code in templates. Does this happen to you? You're adding the finishing touches to a website, including Google Analytics tracking. After registering the site in GA, you have to hunt for that tiny "edit" link in your website profile list, then "check status". After getting your Web property ID, you copy that magic tracking code at the bottom of the page and paste it in your website template. ... or, you could simply type


in your template*, and let the plugin put the code in for you. * See usage below.

Usage

{exp:google_analytics id="UA-9999999-1"} or simply {exp:google_analytics} (if the id is set in config.php)

Parameters

id="UA-9999999-1"

The Google Analytics ID for your site* * If the following setting is added to the config.php file, the id parameter is not needed and is ignored in the template:

$conf['google_analytics_id'] = "UA-9999999-1";
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.

search_tracking="off"

If set to "on" or if the parameter is absent, the plugin will track site search queries on search result pages, i.e. search result pages where the last segment is the EE search id. Set to anything else to turn off.

search_query_parameter="/search/results?query="

Sets the search Query parameter set in Google Analytics. If the parameter is absent and search tracking is on, default is "/search?q=".

Tracking mailto/file download/outbound links

{exp:google_analytics:track link="/downloads/file.zip"}

Use the tag in hyperlinks: <a href="/downloads/file.zip" onclick="{exp:google_analytics:track link="/downloads/file.zip"}">File</a>

Parameters

	link="/downloads/file.zip"

The mailto/file/outbound link to track.

Installation

Copy pi.google_analytics.php to your system/plugins folder.

Changelog

0.1

  • First release
  • Parameter for new or older urchin code
  • Support for Web property ID setting in config.php file

0.2

  • Added search query tracking. Turned on by default and automatically triggered if on search result page
  • Added the {exp:google_analytics:track} tag, to track mailto/file download/outbound links

0.3

  • ExpressionEngine 2.0 conversion kindly provided by Matthieu Fauveau
  • ExpressionEngine 2.0 compatibility
  • Cleaned up the code

0.4

  • Changed some parameters name to reflect Google Analytics documentation
  • Added the ability to set domain name
  • Added the ability to set allow hash
  • Added the ability to set allow linker
  • Added the ability to load the asynchronous tracking code
  • Cleaned up the code
Creative Commons License