Getting the most from your Google Analytics. Session 4 Extending Google Analytics the role of programming technologies and 3rd-party tools

38 

Full text

(1)

Session 4

(2)

https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview

Google Analytics information collection

A default amount of data is collected for every page visited in a Google

Analytics enabled web site by any ordinary user of the site

Google Analytics is enabled by inserting tracking code at the start of every page of the site

This tracking code identifies a Google Analytics account and loads JavaScript code from Google servers

The loaded JavaScript code contains lots of functions that implement the data collection by assembling information and sending it to Google servers where it is stored and used in reports

Google Analytics will not work for non-ordinary users who disable JavaScript, disable cookies, or opt out using other browser add-ons or settings

(3)

https://support.google.com/analytics/answer/1008080

Obtaining the tracking code to be inserted in every page

Sign in to your Google Analytics account

Select Admin in the top menu bar

Select the desired property from the Account and Property columns

(4)

<script type="text/javascript"> var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-11066040-47']); _gaq.push(['_trackPageview']);

(function () {

var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>

An example of tracking code for a web site

Classic ga.

(5)

<script>

(function (i, s, o, g, r, a, m) { i ['GoogleAnalyticsObject'] = r;

i [r] = i [r] || function () {(i [r].q = i [r].q || []).push (arguments)}, i [r].l = 1 * new Date ();

a = s.createElement (o), m = s.getElementsByTagName (o)[0]; a.async = 1;

a.src = g;

m.parentNode.insertBefore (a, m)

}) (window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); ga ('create', 'UA-11066040-24', 'auto');

ga ('send', 'pageview'); </script>

An example of tracking code for a web site

Universal anal

ytics.

(6)

https://developers.google.com/analytics/devguides/platform/

The Google Analytics platform

Web site users

Google Analytics

(7)

Server system information

Local system information, including network related details

Information stored in cookies

No personal information about the user

https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview#trackingCodeExecution

What information is assembled and sent to Google

Server system information

Local system information, including network related details

Information stored in cookies

(8)

https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview#gifParameters

Sending data to Google using the _utm.gif technique

This is a simple web request for a one pixel gif file on Google servers, made by JavaScript code running in the web site page on the user's browsing

device whenever any type of hit is recorded

The requested web address contains a long series of query parameters, the

query string, that together provide all of the assembled information to be

(9)

https://developers.google.com/analytics/resources/concepts/gaConceptsCookies

Google Analytics cookies

Cookies act as local data collectors on the user's device as the user interacts with a web page

They store information from page to page during a session and retain some of that information between sessions, typically:

determining a session start or end identifying unique users

recording traffic sources and navigation storing custom variables

(10)

Collecting extra data for reports

There are occasions when it is desirable to monitor, measure, or analyse something specific to a particular web site—something that cannot be seen using the default amount of collected data

On such occasions simple JavaScript programming in a web page can be added to call some of the functions that are loaded from Google at the start of each web page of the site—often referred to as the Google Analytics data

collection API

These functions will register additional hits in Google Analytics reports to correspond with particular user interactions on a web page

(11)

Different types of hits that can be recorded

A page view, which may be real or virtual

An event that represents a specific user interaction occurrence

A custom variable value is set

A particular social media activity occurs

A timing value is recorded

All of above are now also referred to as tracking beacons in Google Analytics

(12)

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration

Tracking a page view using _trackPageview

Classic ga.js JavaScript methods are normally pushed into an array _gaq that serves as a queue from which each item is executed in turn after all code has been fully loaded into the page

The most basic tracking of a web page view is enabled using a call to the

_trackPageview method with an optional page URL parameter:

_gaq.push (['_trackPageview']);

_gaq.push (['_trackPageview', ‘/home/startPage’]);

Classic ga.

(13)

https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#send

Tracking a page view using send

The Universal Analytics tracking code creates a JavaScript global object named ga in the web page that is used to invoke other Google Analytics JavaScript methods

One of the most common of these methods for recording hits is send

It is used to track a page view, with optional override of the page URL:

ga ('send', 'pageview');

ga ('send', 'pageview', ‘/home/startPage’);

Universal anal

ytics.

(14)
(15)

Using virtual page view hits to track file downloads

File downloads from a web page are not automatically tracked by Google Analytics as they are not web pages with tracking code

However an additional virtual page view can be recorded each time a

download link is selected by including a call to _trackPageview (Classic ga.js) or send (Universal analytics.js) on the download link:

<a href="http://www.example.com/files/myfile01.pdf"

onClick="_gaq.push (['_trackPageview', '/download/file01']);">

myfile01 </a>

<a href="http://www.example.com/files/myfile01.pdf"

onClick="ga (send, pageview, '/download/file01');">

myfile01 </a>

(16)

http://techoctave.com/c7/posts/58-entourage-js-automatic-download-tracking-for-asynchronous-google-analytics

Tracking all file downloads using entourage.js

Avoid the tedium of adding JavaScript code to every file link by using another piece of JavaScript to do it for you!

By loading the entourage.js JavaScript code at the start of the page, all document links will have necessary tracking code added automatically so that the downloads appear in the usual Behavior reports

The entourage.js JavaScript code allows the user to specify what download file extensions should have tracking code added (so limiting the virtual page views to the desired set of downloads)

(17)
(18)

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

Event tracking using _trackEvent

Particular visitor interaction on a web page can be recorded and displayed as an event in the usual Behavior reports by invoking the _trackEvent method as the event occurs on the page:

_gaq.push (['_trackEvent', 'category', 'action', 'label', value, noninteraction])

category—(required) the name you supply for the group of objects you want to track action—(required) a string that is commonly used to define the type of user interaction label—(optional) an optional string to provide additional dimensions to the event data value—(optional) an integer used to provide numerical data about the user event

non-interaction—(optional) set to true to indicate that the event hit will not be used in bounce-rate calculation

Classic ga.

(19)

https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Event tracking using send

The send method can be used to track an event hit type and record any particular user interaction

Parameters have exactly the same meaning as with the Classic ga.js

_trackEvent method:

ga ('send', 'event', 'category', 'action', 'label', value, noninteraction)

category—(required) the name you supply for the group of objects you want to track action—(required) a string that is commonly used to define the type of user interaction label—(optional) an optional string to provide additional dimensions to the event data value—(optional) an integer used to provide numerical data about the user event

non-interaction—(optional) set to true to indicate that the event hit will not be used in bounce-rate calculation

Universal anal

ytics.

(20)

Event tracking example

Using a simple form to poll a user's interest on a web page, track the values of any responses as events

(21)

Event tracking example

<input type="radio" id="vV1" value="positive"> Yes <input type="radio" id="vV0" value="negative"> No <input type="submit" value="Submit" onclick="

var vVote = document.getElementById ('vV1').checked ? document.getElementById ('vV1').value :

(document.getElementById ('vV0').checked ? document.getElementById ('vV0').value : 0); var vValue = (vVote == 'positive') ? 1 : 0; if (vVote) {

alert ('Thanks for the useful ' + vVote + ' feedback!');

_gaq.push (['_trackEvent', 'User feedback',

'Submitted interest in page', vVote, vValue, 0]);

}

">

Classic ga.

js

Set variable vVote to either "positive" or "negative" depending on which option was selected,

and 0 if none selected

Set variable vValue to 1 if vVote is "positive",

otherwise set to 0

(22)

Event tracking example

<input type="radio" id="vV1" value="positive"> Yes <input type="radio" id="vV0" value="negative"> No <input type="submit" value="Submit" onclick="

var vVote = document.getElementById ('vV1').checked ? document.getElementById ('vV1').value :

(document.getElementById ('vV0').checked ? document.getElementById ('vV0').value : 0); var vValue = (vVote == 'positive') ? 1 : 0; if (vVote) {

alert ('Thanks for the useful ' + vVote + ' feedback!');

ga ('send', 'event', 'User feedback',

'Submitted interest in page', vVote, vValue, 0);

} ">

Universal anal

ytics.

(23)
(24)

https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

Recording custom variables with _setCustomVar

You can set up custom variables with values that are recorded and appear in reports to reveal particular things about users activity on pages of your site

Relevant reports appear in the Audience main reports section

The _setCustomVar method is used as follows:

_gaq.push (['_setCustomVar', index, 'name', 'value', scope])

index—the slot for the custom variable (required), this is a number whose value can range from 1 - 5, inclusive

name—the name for the custom variable (required), this is a string that identifies the variable and appears in reports value—the value for the custom variable (required)

scope—the scope for the custom variable (optional), 1 = visitor-level, 2 = session-level, 3 = page-level (default)

Classic ga.

(25)

https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

Recording custom variables with custom dimensions and set

Universal analytics.js no longer supports setting custom variables—although Universal reporting still displays historical custom variables information in the relevant Audience Custom report

Universal allows the addition of custom dimensions—up to 20 for each property—managed through the property Admin Custom Definitions option

Each new dimension is created with an appropriate name and assigned a numeric index which increments from 1 to 20

A value for the new dimension can be provided on any page using JavaScript with the set method, identifying the dimension with label 'dimension' and the relevant index as a suffix:

ga ('set', 'dimensionx', 'value')

Universal anal

ytics.

(26)

https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

The Universal custom dimension management option

Universal anal

ytics.

(27)

Custom variables example

For a site with a registered user login facility, it may be desirable to record the userID of a user that has logged in, then review logins of users over time

The value of a particular userID will be available to the code that is generating the web page as, say, variable $userID

This can be recorded in Google Analytics data using _setCustomVar (Classic ga.js) or set (Universal analytics.js) using one of the following in the page:

<script type="text/JavaScript">

_gaq.push (['_setCustomVar', 5, 'visitorUserID', $userID, 1]);

</script>

<script type="text/JavaScript">

ga ('set', 'dimension1', $userID);

</script>

index of custom variable—seen in Custom

Variables report in Audience main report section

index of custom dimension with assumption that it has been created for the property—seen in many reports

(28)
(29)

Helpful third party extensions to Google Analytics

In addition to entourage.js (automatically inserting JavaScript around links) there many other scripts, applications, configuration files and other software gadgets to enable easier management and richer functionality in your use of Google Analytics

So sometimes a ready-made solution may be available to fulfill your requirements, removing the need for manual custom programming

The largest single collection of these Google Analytics extensions can be found in the Google Analytics app gallery

(30)

http://www.google.com/analytics/apps/

(31)

http://www.google.com/analytics/apps/about?app_id=1330001

App gallery example—mobile analytics

Keep track of what's happening on your site when on the move

(32)

http://www.google.com/analytics/apps/about?app_id=2388001

App gallery example—infographics

Use a service in the cloud to send you weekly reports using an infographic style

(33)

Using Google Analytics with other Google services

Google allows Google Analytics reporting to be used with other Google services, most notably Google's Webmaster Tools and Adwords

These extensions to the available reports in Google Analytics are enabled by connecting the different Google service accounts, and in so doing

(34)

Google's Webmaster Tools provides an authorised owner of a web site access to information about how that web site has performed on Google's search engine—primarily regarding what search words have caused the site to appear in search results and how often the site has been selected in results

Connecting a Google Analytics property to the same site in Webmaster Tools activates a number of extra reports under the title Search Engine Optimization in the Acquisition reports section that provide tangible metrics on how well Google's search engine is bringing users to your web site

To connect:

add and verify the web site at http://www.google.com/webmasters/

in Google Analytics select Webmaster Tools Settings in the property Admin Property Settings and follow instructions

http://support.google.com/analytics/bin/answer.py?hl=en&answer=1308617

(35)
(36)

http://www.youtube.com/watch?v=05we2g3Edgs https://support.google.com/analytics/answer/1033961

Google Adwords

Adwords is a Google service that involves privileged visibility in Google search results listings whenever particular paid for adwords are searched for by any search engine user

Connecting a Google Analytics property to a corresponding Adwords account activates extra reports under title Adwords in the Acquisition reports section

These provide metrics on how effectively the paid for search words are bringing users to your web site

To connect:

in Google Analytics select Adwords Linking in the property Admin create a new link group and follow instructions

(37)

https://support.google.com/analytics/bin/answer.py?hl=en-GB&answer=1247853&topic=1308583&parent=1631776&rd=1

(38)

Summary

Google Analytics data collection

The tracking code inserted in every page

What information is assembled and sent to Google

Google Analytics cookies and the _utm.gif data transfer technique

Collecting extra data using JavaScript methods

Google Analytics app gallery extensions for enhanced functionality

Google webmaster tools connection for extra SEO reports

Figure

Updating...

References

Updating...

Related subjects :