EXT: RS Google Analytics

Extension Key: rsgoogleanalytics

Language: en

Version: 3.1.0

Keywords: forAdmins, forIntermediates

Copyright 2006-2012, Steffen Ritter <info@rs-websystems.de>, François Suter <typo3@cobweb.ch>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.org

Table of Contents

EXT: RS Google Analytics	1

Introduction	3

What does it do?	3

Installation	4

Base setup	4

Upgrading to version 3.0	4

Configuration	5

Constants	5

Setup	5

Developer's Guide	7

E-Commerce tracking API	7

Hooks	7

Known problems	8

To-Do list	9

Introduction

What does it do?

This extension simplifies the installation and usage of Google Analytics tracking code. It can use either the traditional or the asynchronous method and enables most of the options provided by the Google Analytics API. The main code itself is inserted via a customizable template.

Installation

Base setup

Install the extension and include the appropriate static TypoScript. There are four different files:

Legacy Setup: this is just for backwards-compatibility reasons, don't use it on a new system.

General Setup: this file contains all the configuration options for the extensions.

Traditional Method: this file contains the code to include the necessary JavaScript using the traditional method.

Asynchronous Method: this file contains the code to include the necessary JavaScript using the asynchronous method.

Notes

The two "Method" files assume that your main page object is called "PAGE". If this is not the case, don't use these files. Copy their content to your own template and change the name to the one that you are using.

Including the "Asynchronous Method" is not enough, the relevant TypoScript properties must be changed too, i.e. the "asynchronous" and "templateFile" properties (see "Configuration" chapter).

Upgrading to version 3.0

Everything was done to ensure backwards-compatibility, so upgrading should not break anything. However to benefit from the new features – in particular the use of the asynchronous method for calling up Google Analytics – you will need to change the static TypoScript files used. Refer to the preceding paragraph and to the "Configuration" chapter.

Configuration

There exists a number of TypoScript properties that can be used to configure this extension. They are listed below.

Constants

Property:	Data type:	Description:	Default:
active	boolean	Whether plugin is active or not	1
asynchronous	boolean	Whether traditional or asynchronous method should be used (set to 1 for asynchronous). Beware to be consistent with template file	1
account	string	Your Google-Analytics account number. Default is a test account of RS WebSystems	UA-1628673-4
templateFile	file	File containing the JavaScript code template	EXT:rsgoogleanalytics/res/templates/codeAsynchronous.js

Setup

Property:	Data type:	Description:	Default:
templateFile	resource	File containing the JavaScript code template	{$plugin.tx_rsgoogleanalytics.templateFile}
asynchronous	boolean	Whether traditional or asynchronous method should be used (set to 1 for asynchronous). Beware to be consistent with template file	{$plugin.tx_rsgoogleanalytics.asynchronous}
active	boolean	Whether plugin is active or not	{$plugin.tx_rsgoogleanalytics.active}
account	string	Your Google Analytics account number. Default is a test account of RS WebSystems	{$plugin.tx_rsgoogleanalytics.account}
registerTitle	string	Which kind of page title should be tracked. If empty, Google Analytics will use the path part of the URL. Options title: Page title is used rootline: Rootline of page titles is used	rootline
trackDownloads	string	Should downloads be tracked by GA. Set value to !ALL, to track all downloads regardless of other options (see below).	1
trackDownloads.folderList	string	Folders from which downloads should be tracked only (comma-separated list)	fileadmin/,uploads/
trackDownloads.fileTypes	string	Restrict download tracking to specific file types (comma-separated list).	pdf,doc
trackExternals	string	Track external links. Set value to !ALL to track all external URLs regardless of other options (see below)	1
trackExternals.domainList	string	Restrict tracking of external links to to these domains (comma-separated list)	amazon.com,typo3.org
multipleDomains	boolean	Set to 1 if you have multiple domains enabled for this site	0
multipleDomains.domainNames	string	Comma-separated list of domains	
trackSubDomains	boolean	Enable tracking for a specific domain (will not work if "multipleDomains" is enabled	0
trackSubDomains.domainName	string	Domain to track	example.com
searchEngines.redirectKeywords	string	Comma-separated list of keywords to consider as direct access	my name, my domain, city and company name
searchEngines.redirectReferrer	string	Comma-separated list of referrers to consider as direct access	example.net,domain2-redirected.de,my-web-agency.de
customVars	array	Custom variables to send along with the tracking information. Each array item has stdWrap properties.	1 { name = gender scope = 1 data = TSFE:fe_user|user|gender } 2 { name = name scope = 1 data = TSFE:fe_user|user|name }
visitorSegment	stdWrap	Name of the visitor, passed along with the tracking information.	data = TSFE:fe_user|user|name
eCommerce.enableTracking	boolean	Enable tracking of e-commerce transactions	true
disableDataTracking.browserInfo	boolean	Disables logging of browser information.	0
browsdisableDataTracking.flashTest	boolean	Disables detection of Flash installation and version.	0
BrowsdisableDataTracking.pageTitle	boolean	Disables storage of page title.	0
disableDataTracking.anonymizeIp	boolean	Anonymizes IP address (required by German law, for example)	1

[tsref:plugin.tx_rsgoogleanalytics]

Developer's Guide

E-Commerce tracking API

Developers of e-Commerce extensions can use this extension's API to hand over information regarding a purchase to be tracked by Google Analytics.

According to the ruleset of Google Analytics you may track the following pieces of information:

Total order

Information about each basket Item.

If you want to track information about each basket item, the total order information is a pre-requisite and must match the sum of the basket items.

Example

if (t3lib_extMgm::isLoaded('rsgoogleanalytics')) {

/** @var tx_rsgoogleanalytics $GA */

$GA = t3lib_div::makeInstance('tx_rsgoogleanalytics');

$GA->addCommerceTransaction($order->getId(), 'OnlineShop', $order->getTotalGross(), $order->getTaxAmountHigh() + $order->getTaxAmountLow(),0, $order->getBillAddress()->getCity(), '', 'DE');

/** @var Tx_*_Domain_Model_OrderPosition $position */

foreach ($order->getPositions() AS $position) {

$GA->addCommerceItem($order->getId(), $position->getArticle()->getSku(), $position->getArticle()->getTitle(), $position->getArticle()->getProduct()->getSeries()->getTitle(),

}

}

The addCommerceTransaction() method expects eight parameters, related to the order, namely:

the id of the order

a name identifying the store where the order was placed

the total amount of the order

the amount of taxes and shipping

the city, state and country of destination

The addCommerceItem() method expects six parameters, related to each item in the shopping basket:

the id of the order

the id (sku) of the item

the name of the item

the category it belongs to

the price

the ordered quantity

Hooks

The extension provides the following hook:

processPageName: this hook makes it possible to manipulate the page name for special needs. It receives as arguments the page name calculated so far (if at all) and a back-reference to the tx_rsgoogleanalytics object. It must return the page name, even if unchanged.

Known problems

None to date. Please report problems by opening a bug report at http://forge.typo3.org/projects/extension-rsgoogleanalytics/issues.

To-Do list

Check the roadmap on the project's page on Forge: http://forge.typo3.org/projects/extension-rsgoogleanalytics/roadmap

For feature request, please open a report at http://forge.typo3.org/projects/extension-rsgoogleanalytics/issues

EXT: RS Google Analytics - rsgoogleanalytics	Known problems

9

EXT: RS Google Analytics

rsgoogleanalytics

forAdmins forIntermediates

Christopher

2010-12-18T19:57:23