DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: RS Google Analytics

Author:Christopher
Created:2010-12-18T19:57:23
Changed:2012-12-10T13:23:38
Classification:rsgoogleanalytics
Keywords:forAdmins, forIntermediates
Author:Steffen Ritter, François Suter
Email:info@rs-websystems.de, typo3@cobweb.ch
Language:en

img-1 img-2 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 <#__RefHeading__5708_1738894311>`_

`Introduction 3 <#__RefHeading__5710_1738894311>`_

What does it do? 3

`Installation 4 <#__RefHeading__467_413120346>`_

Base setup 4

Upgrading to version 3.0 4

`Configuration 5 <#__RefHeading__31515_818911409>`_

Constants 5

Setup 5

`Developer's Guide 7 <#__RefHeading__31525_818911409>`_

E-Commerce tracking API 7

Hooks 7

`Known problems 8 <#__RefHeading__644_2108705915>`_

`To-Do list 9 <#__RefHeading__477_413120346>`_

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:

img-3 - 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

active

Property

active

Data type

boolean

Description

Whether plugin is active or not

Default

1

asynchronous

Property

asynchronous

Data type

boolean

Description

Whether traditional or asynchronous method should be used (set to 1 for asynchronous). Beware to be consistent with template file

Default

1

account

Property

account

Data type

string

Description

Your Google-Analytics account number. Default is a test account of RS WebSystems

Default

UA-1628673-4

templateFile

Property

templateFile

Data type

file

Description

File containing the JavaScript code template

Default

EXT:rsgoogleanalytics/res/templates/codeAsynchronous.js

Setup

templateFile

Property

templateFile

Data type

resource

Description

File containing the JavaScript code template

Default

{$plugin.tx_rsgoogleanalytics.templateFile}

asynchronous

Property

asynchronous

Data type

boolean

Description

Whether traditional or asynchronous method should be used (set to 1 for asynchronous). Beware to be consistent with template file

Default

{$plugin.tx_rsgoogleanalytics.asynchronous}

active

Property

active

Data type

boolean

Description

Whether plugin is active or not

Default

{$plugin.tx_rsgoogleanalytics.active}

account

Property

account

Data type

string

Description

Your Google Analytics account number. Default is a test account of RS WebSystems

Default

{$plugin.tx_rsgoogleanalytics.account}

registerTitle

Property

registerTitle

Data type

string

Description

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

Default

rootline

trackDownloads

Property

trackDownloads

Data type

string

Description

Should downloads be tracked by GA. Set value to !ALL , to track all downloads regardless of other options (see below).

Default

1

trackDownloads.folderList

Property

trackDownloads.folderList

Data type

string

Description

Folders from which downloads should be tracked only (comma-separated list)

Default

fileadmin/,uploads/

trackDownloads.fileTypes

Property

trackDownloads.fileTypes

Data type

string

Description

Restrict download tracking to specific file types (comma-separated list).

Default

pdf,doc

trackExternals

Property

trackExternals

Data type

string

Description

Track external links. Set value to !ALL to track all external URLs regardless of other options (see below)

Default

1

trackExternals.domainList

Property

trackExternals.domainList

Data type

string

Description

Restrict tracking of external links to to these domains (comma- separated list)

Default

amazon.com,typo3.org

multipleDomains

Property

multipleDomains

Data type

boolean

Description

Set to 1 if you have multiple domains enabled for this site

Default

0

multipleDomains.domainNames

Property

multipleDomains.domainNames

Data type

string

Description

Comma-separated list of domains

Default

trackSubDomains

Property

trackSubDomains

Data type

boolean

Description

Enable tracking for a specific domain (will not work if "multipleDomains" is enabled

Default

0

trackSubDomains.domainName

Property

trackSubDomains.domainName

Data type

string

Description

Domain to track

Default

example.com

searchEngines.redirectKeywords

Property

searchEngines.redirectKeywords

Data type

string

Description

Comma-separated list of keywords to consider as direct access

Default

my name, my domain, city and company name

searchEngines.redirectReferrer

Property

searchEngines.redirectReferrer

Data type

string

Description

Comma-separated list of referrers to consider as direct access

Default

example.net,domain2-redirected.de,my-web-agency.de

customVars

Property

customVars

Data type

array

Description

Custom variables to send along with the tracking information.

Each array item has stdWrap properties.

Default

1 {

name = gender

scope = 1

data = TSFE:fe_user|user|gender

}

2 {

name = name

scope = 1

data = TSFE:fe_user|user|name

}

visitorSegment

Property

visitorSegment

Data type

stdWrap

Description

Name of the visitor, passed along with the tracking information.

Default

data = TSFE:fe_user|user|name

eCommerce.enableTracking

Property

eCommerce.enableTracking

Data type

boolean

Description

Enable tracking of e-commerce transactions

Default

true

disableDataTracking.browserInfo

Property

disableDataTracking.browserInfo

Data type

boolean

Description

Disables logging of browser information.

Default

0

browsdisableDataTracking.flashTest

Property

browsdisableDataTracking.flashTest

Data type

boolean

Description

Disables detection of Flash installation and version.

Default

0

BrowsdisableDataTracking.pageTitle

Property

BrowsdisableDataTracking.pageTitle

Data type

boolean

Description

Disables storage of page title.

Default

0

disableDataTracking.anonymizeIp

Property

disableDataTracking.anonymizeIp

Data type

boolean

Description

Anonymizes IP address (required by German law, for example)

Default

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.

((generated))
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 thetx_rsgoogleanalyticsobject. 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