SlideShare a Scribd company logo
Exploring the Google Analytics API
Vanessa Sabino
@bani
Google Analytics
It’s all about Data
•  Web sites
•  Mobile apps
•  Coffee makers*
•  Etc.
* http://youtu.be/C27yMQOS8n0
Google Analytics
Goals & Conversion Optimization
The Core Reporting API
https://developers.google.com/analytics/devguides/reporting/core/v3/
Why use the API?
1.  Productivity
(and less sampling)
http://xkcd.com/303/
Why use the API?
1.  Productivity
2.  + Results
max-results=10,000
Why use the API?
1.  Productivity
2.  + Results
3.  + Dimensions
Up to 7 dimensions!
Why use the API?
1.  Productivity
2.  + Results
3.  + Dimensions
4.  Visualization
http://tinyurl.com/GA-Apps
Why use the API?
1.  Productivity
2.  + Results
3.  + Dimensions
4.  Visualization
5.  Web apps
http://sumall.com/
Why use the API?
1.  Productivity
2.  + Results
3.  + Dimensions
4.  Visualization
5.  Web apps
6.  Data storage
API Concepts
Metrics & Dimensions
https://developers.google.com/analytics/devguides/reporting/core/dimsmets
Filters & Segments
Metrics
== Equals
!= Does not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Dimensions
== / != Exact match
=@ / !@ Contains substring
=~ / !~ Contains a match for
the regular expression
, Or
; And
https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filterSyntax
Data Feed
https://www.googleapis.com/analytics/v3/data/ga
?ids=ga:12345 *
&dimensions=ga:source,ga:medium
&metrics=ga:visits,ga:bounces *
&sort=-ga:visits
&filters=ga:medium%3D%3Dreferral
&segment=gaid::10
&start-date=2011-10-01 *
&end-date=2011-10-31 *
&start-index=10
&max-results=100
&prettyprint=true
* = required
Query Explorer
http://tinyurl.com/gdata-explorer
Steps to use the API
1.  Authenticate
2.  Get your data
3. 
Register your Project
https://code.google.com/apis/console
oAuth Authentication
client_secrets.json
{	
  
	
  	
  "installed":	
  {	
  
	
  	
  	
  	
  "auth_uri":"https://accounts.google.com/o/oauth2/auth",	
  
	
  	
  	
  	
  "client_secret":"CleKR0UzPYhfTbjPb3TgeQRBw",	
  
	
  	
  	
  	
  "token_uri":"https://accounts.google.com/o/oauth2/token",	
  
	
  	
  	
  	
  "client_email":"",	
  
	
  	
  	
  	
  "redirect_uris":["urn:ietf:wg:oauth:2.0:oob","oob"],	
  
	
  	
  	
  	
  "client_x509_cert_url":"",	
  
	
  	
  	
  	
  "client_id":"395901729588.apps.googleusercontent.com",	
  
	
  	
  	
  	
  "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/
certs"	
  
	
  	
  }	
  
}	
  
Python Library
¤ Python: Versions 2.5, 2.6, or 2.7
¤ easy_install / pip google-api-python-client
¤ Download file for Google AppEngine
¤  https://developers.google.com/api-client-library/
python/start/installation
Authorize
¤ Copy hello_analytics_api_v3_auth.py
	
  
import	
  auth_helper	
  
from	
  apiclient.errors	
  import	
  HttpError	
  
from	
  oauth2client.client	
  	
  
import	
  AccessTokenRefreshError	
  
	
  
service	
  =	
  	
  
auth_helper.initialize_service()	
  
Get your data
* https://www.google.com/analytics/web/?hl=en&pli=1#dashboard/
ViBLgd51S7YHgitTK4MoYQ/a4126737w34427220p33794370/
	
  
service.data().ga().get(	
  
	
  	
  ids='ga:'	
  +	
  profile_id*,	
  
	
  	
  start_date='2013-­‐07-­‐01',	
  end_date='2013-­‐08-­‐01',	
  
	
  	
  metrics='ga:visits',	
  dimensions='ga:source',	
  
	
  	
  sort='-­‐ga:visits,ga:source',	
  
	
  	
  filters='ga:medium==organic',	
  
	
  	
  max_results='25').execute()	
  
CoreReportingAPIQuery
Handle the results
	
  
for	
  row	
  in	
  results.get('rows'):	
  
	
  	
  output	
  =	
  []	
  
	
  	
  for	
  cell	
  in	
  row:	
  
	
  	
  	
  	
  output.append('%16s'	
  %	
  cell)	
  
	
  	
  print	
  ''.join(output)	
  
Handle the results
	
  
for	
  header	
  in	
  	
  
results.get('columnHeaders'):	
  
	
  	
  print	
  '%s:	
  %s	
  -­‐	
  %s'	
  %	
  (	
  
	
  	
  	
  	
  header.get('name'),	
  
	
  	
  	
  	
  header.get('columnType'),	
  
	
  	
  	
  	
  header.get('dataType'))	
  
ga:source: DIMENSION - STRING
ga:visits: METRIC - INTEGER
Handle the results
	
  
totals	
  =	
  	
  
results.get('totalsForAllResults')	
  
	
  
for	
  metric_name,	
  metric_total	
  	
  
in	
  totals.iteritems():	
  
	
  	
  print	
  '%s	
  =	
  %s'	
  %	
  	
  
	
  	
  (metric_name,	
  metric_total)	
  
More data
¤ results.get('containsSampledData')
¤ results.get('profileInfo')
¤ info.get('webPropertyId') # UA-XXXXXXX-X
¤ info.get('profileId')
¤ info.get('profileName')
¤ results.get('itemsPerPage')
¤ results.get('totalResults’)
Limits and Quotas
¤ Quotas
¤ 10,000 requests / profile/ day
¤ 10 concurrent requests per profile
¤ Dimensions and Metrics
¤ 7 dimensions
¤ 10 metrics
¤ Valid combinations
¤ Regular expressions: 128 characters
Other Google Analytics APIs
¤ Multi-Channel Funnels Reporting API
¤  https://developers.google.com/analytics/devguides/reporting/mcf/v3/
¤ Management API
¤  https://developers.google.com/analytics/devguides/config/mgmt/v3/
¤ Real Time Reporting API
¤  http://analytics.blogspot.ca/2013/08/google-analytics-launches-real-
time-api.html
¤ See also: Google Analytics superProxy
¤  https://developers.google.com/analytics/solutions/google-
analytics-super-proxy
Exploring the Google Analytics API
Thank you
Vanessa Sabino
@bani
vanessa@weureka.com
http://www.slideshare.net/vanessasabino/

More Related Content

PPTX
I/O Rewind 215: What's new in Android
PDF
Advanced Structured Data: Beyond Rich Snippets
PDF
How to Setup App Indexation
DOCX
4.preference management
PPTX
07.1. Android Even Handling
PPTX
Quantified Sleep: Measuring sleep quality with Sleep as Android
PDF
Licenças de Software Livre
PDF
Um Usuário, Múltiplos Canais
I/O Rewind 215: What's new in Android
Advanced Structured Data: Beyond Rich Snippets
How to Setup App Indexation
4.preference management
07.1. Android Even Handling
Quantified Sleep: Measuring sleep quality with Sleep as Android
Licenças de Software Livre
Um Usuário, Múltiplos Canais

Viewers also liked (10)

PDF
What a Long, Strange Trip it Is
PDF
Best practise 5 anwendungsfälle der google analytics api
PPTX
Google Analytics Measurement Protocol: Einführung, Transaktionen & Stornos
PPTX
Lifelogging mit IFTTT und dem GA Measurement Protocol
PPTX
Stop Spam in Google Analytics
PPT
Seocampixx 2016 - Data Mining Reloaded - In 30 Minuten zum eigenen Scraper
PDF
Realtime SEO
PPTX
Logfile-Analyse: Wo ver(sch)wendet Google Crawling-Ressourcen? | Stephan Czys...
PDF
Leistungsstarke Remarketing-Listen mit Google Analytics
PPTX
Quantified self – wie vermesse ich mich selbst
What a Long, Strange Trip it Is
Best practise 5 anwendungsfälle der google analytics api
Google Analytics Measurement Protocol: Einführung, Transaktionen & Stornos
Lifelogging mit IFTTT und dem GA Measurement Protocol
Stop Spam in Google Analytics
Seocampixx 2016 - Data Mining Reloaded - In 30 Minuten zum eigenen Scraper
Realtime SEO
Logfile-Analyse: Wo ver(sch)wendet Google Crawling-Ressourcen? | Stephan Czys...
Leistungsstarke Remarketing-Listen mit Google Analytics
Quantified self – wie vermesse ich mich selbst
Ad

Similar to Exploring the Google Analytics API (20)

PDF
GA Konferenz-2011 Nick Mihailovski_API
PPTX
Digital analytics with R - Sydney Users of R Forum - May 2015
PDF
Interactively querying Google Analytics reports from R using ganalytics
PPTX
Google Analytics Fundamentals
PPTX
Florian Pertynski session at Google Partner Summit Review
PDF
AnDevCon - Tracking User Behavior Creatively
PPTX
Usando metodologías ágiles en UX
PDF
Google Analytics 101
PPTX
APIs and Efficiency SEOProSco Presentation 18th Oct 2012
PDF
Advanced Google Analytics Techniques
PPT
Google Analytics User Conference - Nick Mihailovski, Amsterdam May 19th 2011 ...
PDF
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
PPTX
Google analytics concepts introduction
PDF
Google Analytics for Developers
PPTX
analytics.pptx
PPTX
Presentazione Google Analytics
PDF
Cómo usar google analytics
PDF
Google Analytics Overview
PPTX
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
PDF
Importance of Google Analytics in Future
GA Konferenz-2011 Nick Mihailovski_API
Digital analytics with R - Sydney Users of R Forum - May 2015
Interactively querying Google Analytics reports from R using ganalytics
Google Analytics Fundamentals
Florian Pertynski session at Google Partner Summit Review
AnDevCon - Tracking User Behavior Creatively
Usando metodologías ágiles en UX
Google Analytics 101
APIs and Efficiency SEOProSco Presentation 18th Oct 2012
Advanced Google Analytics Techniques
Google Analytics User Conference - Nick Mihailovski, Amsterdam May 19th 2011 ...
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Google analytics concepts introduction
Google Analytics for Developers
analytics.pptx
Presentazione Google Analytics
Cómo usar google analytics
Google Analytics Overview
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
Importance of Google Analytics in Future
Ad

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Network Security Unit 5.pdf for BCA BBA.
Programs and apps: productivity, graphics, security and other tools
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction

Exploring the Google Analytics API