This presentation was given at Google DevFest Kuala Lumpur on 29 Sep 2011. This presentation covers how to implement Google Analytics' advanced tracking features, including: event tracking, social plugin tracking, custom variables, page load time tracking, mobile site tracking, iOS and Android application tracking, and campaign variables.
3. The Role of the Web Analyst
Reporting
Actionable Insights
http://www.flickr.com/photos/kire/797533507/sizes/o/in/photostream/
4. What does “Action” mean?
Discovering new opportunities
(eg. New markets, hot trends, customer segments)
Optimisation
Improving marketing strategies
Maximising reach
(eg. New markets, optimise messaging)
of your apps and
delighting users
Enhancing the user experience
(eg. Compelling content, optimal user flows)
5. Agenda
• How GA Works
• Tracking
– Basics
– Event Tracking
– Custom Variables
– Social Interaction Tracking
– Campaign Variables
– Page Load Time Tracking
• Mobile Tracking
– WAP
– Android and iOS
• Tracking Other Platforms
16. Understand the website structure
Single Multiple
domain domains
Multiple
sub- Multiple domains
domains and multiple sub-
domain
17. Simplest GATC Installation
• All content on a single domain
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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>
18. GATC – Multiple Sub-Domains
• Content exists on multiple sub-domains on a single top-level domain
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', '.mysite.com']);
_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>
19. GATC – Multiple Domains
• Content exists on multiple top-level domains
_link()
<script type="text/javascript"> Update all links between domains to include the _link() method.
var _gaq = _gaq || []; <a href=“http://www.mysite-support.com” onclick=“_gaq.push
_gaq.push(['_setAccount', 'UA-XXXXX-X']); ([‘_link’, this.href]);”>Support</a>
_gaq.push(['_setDomainName', ’none']);
_gaq.push(['_setAllowLinker', true]);
_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>
20. GATC – Multiple Domains and Sub-Domains
• Content exists on multiple sub-domains on multiple top-level domain
_link()
Update all links between domains to
<script type="text/javascript"> include the _link() method.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']); Do not change links between sub-
_gaq.push(['_setDomainName', ’.mysite.com']); domains on the same top-level
_gaq.push(['_trackPageview']); domain.
(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>
21. Linking
When content exists on multiple domains use linking methods to pass cookie
information between domains:
• For HTTP GET include the _link() method.
_link()
• Cookie info in URL parameters
• Redirects user to the new URL
<a href=“http://www.example.com” onclick= “_gaq.push([‘_link’, this.href]);”>Example</a>
• For HTTP POST include the _linkByPost() method.
• Cookie info in action value
• Used for forms and iFrames on other domains
SUBMIT
<form action="http://www.shoppingcart.com/form.php" name="f" method="post”
onsubmit=”_gaq.push([‘_linkByPost’, this]);">
. . . </form>
24. What about the 1-page App/Site?
• Single URL, no page refreshes
25. Enter Event Tracking
• Track events on your site
• Detect events and trigger tracking call
_gaq.push(['_trackEvent', Purpose Example
category, Group of objects being 'Markers'
action, tracked
Type of user interaction 'Click'
opt_label, with the object
opt_value]); Additional info about 'Google
the event Singapore'
Numerical data about 1
the event
2
5
32. Custom Variables: Extended Measurement Model
Behaviour
Entry Exit
Engagement
125+ Metrics and Dimensions+ X Custom Variables = Custom Measurement
Platform
3
2
33. Custom Variables
_setCustomVar(index, name, value, opt_scope);
• index – position to store and transmit the variable (1 to 5)
• name – variable name (e.g. “member-type”) (case sensitive)
• value – variable value (e.g. “premium”) (case sensitive)
• opt_scope – 1:visitor-level; 2:session-level; 3:page-level (default: 3)
• Note: Length of Name + Value cannot exceed 64 characters
_setCustomVar(1, ‘foo’, ‘bar’, 2);
34. Visitor Level Custom Variables
• Stays with the visitor across multiple visits
to the site
• Cannot store personally identifiable
information
_setCustomVar(
1,
‘MembershipLevel’,
‘Platinum’,
1);
35. Session Level Custom Variables
• Labels a session
• Variable is discarded once session ends
_setCustomVar(
3,
‘UsedChatWidget’,
‘true’,
2);
36. Page Level Custom Variables
• Useful for content grouping
• Identify groups of pages according to
attributes other than the page URL
_setCustomVar(
5,
‘Author’,
‘John Jane Doe’,
3);
39. What is social plugin tracking?
Social plugin tracking in Analytics
shows you:
• How social plugins are used
• Behavior of socially engaged users
• Comparative performance of different social plugins
• What content is socially engaging
40. Setup for +1 button
Setup for the button: None
The +1 button on your website is already tracked.
41. Setup for other networks
• Other social buttons require a small javascript change to
your website.
When a social plugin is used call this method:
_trackSocial(network, action, target_url);
52. Campaign Variable Basics
Required Tags
The Source is where the visitor was sent from.
Examples: google, nytimes.com, facebook.com
The Medium is the channel in which this URL is promoted.
Examples: cpc, display, social, organic
The Campaign should either indicate the overarching name for the
marketing effort or just the specific ad campaign in which the ad
lives.
Optional Tags
The Keyword is the search term that you bid on (search engines
only)
The Ad Content should indicate the ad name, copy, or other
helpful information to identify the type of ad that was clicked.
65. Before & After
Amari Package Selection Original
Page Page
Page Speed Score 62 / 100
First View Load Time 8.739s
Optimizations include:
• Removed whitespace in HTML
• Using minified versions of JS libraries
• Using minified CSS
• Serving optimised images
• Testing serving GZIPped (compressed) content
66. Before & After
Amari Package Selection Original Optimized %
Page Page Page Change
Page Speed Score 62 / 100 67 / 100 5%
First View Load Time 8.739s 7.738s 11.5%
Optimizations include:
• Removed whitespace in HTML
• Using minified versions of JS libraries
• Using minified CSS
• Serving optimised images
• Testing serving GZIPped (compressed) content
68. Mobile Tracking
HTML &
WAP
Applications
iPhone
Windows
Mobile
Blackberry
Android
Pearl &
Curve
http://code.google.com/apis/analytics/docs/tracking/mobileAppsTracking.html
6
8
69. Track Activity to Mobile Websites [link]
Mobile Websites
ü Server-side tracking
ü Track all web-enabled devices (not just JS & cookie capable)
ü Four languages supported: PHP, Perl, JSP, ASP
ü Works just like Analytics on desktop web pages
71. A Quick Look at the PHP Code Snippet
Insert a pixel for tracking
Page rendering script
Generate the pixel URL
Send the request to GA
ga.php
7
1
72. Server-to-Server Communications
Secure Google Servers
Website Server
Request pixel: Send request to
/ga.php?.... GA servers
7
2
73. Google Analytics Mobile SDK
Native App Tracking
Unique Users
Pageviews
Events
Ecommerce
Custom Variables
Android Market Referrals
74. Setting Up A Tracker Object In An Activity
GoogleAnalyticsTracker tracker;
onCreate
tracker = GoogleAnalyticsTracker.getInstance();
tracker.startNewSession("UA-xxx-y", this);
74
75. Dispatching Events
Tracked data is queued and dispatched in bundles
• Saves battery life
• Can track when users are offline
tracker.dispatch();
- or -
tracker.start("UA-xxx-y", 20, this);
75
98. • Data is Gold
• Tag & Track
• GA Tracking Code
• Event Tracking
• Custom Variables
• Social Interaction Tracking
• Campaign Variables
• Page Load Time Tracking
• Take Action!!