Explorando a API do Google Analytics
-
Upload
johann-vivot -
Category
Documents
-
view
804 -
download
2
description
Transcript of Explorando a API do Google Analytics
![Page 1: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/1.jpg)
Explorando a API do Google Analytics
Johann Vivot, Direct Performance
@johannvivot
Vanessa Sabino, Dafiti
@weureka
![Page 2: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/2.jpg)
O que faz a API do Google Analytics?
read-only
![Page 3: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/3.jpg)
Duas possibilidades
Management API Data Export API
ContasPerfisMetas
Segmentos
Contas eRelatórios
![Page 4: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/4.jpg)
Por que usar a API?
1. ProdutividadeLoading…
http://xkcd.com/303/
![Page 5: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/5.jpg)
Por que usar a API?
1. Produtividade
2. Mais resultados
max-results=10.000
![Page 6: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/6.jpg)
Por que usar a API?
1. Produtividade
2. Mais resultados
3. Mais dimensões
até 7 dimensões!
![Page 7: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/7.jpg)
Por que usar a API?
1. Produtividade
2. Mais resultados
3. Mais dimensões
4. Visualização
http://tinyurl.com/GA-Apps
![Page 8: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/8.jpg)
Por que usar a API?
1. Produtividade
2. Mais resultados
3. Mais dimensões
4. Visualização
5. Serviços Web
http://paditrack.com/
![Page 9: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/9.jpg)
Por que usar a API?
1. Produtividade
2. Mais resultados
3. Mais dimensões
4. Visualização
5. Serviços Web
6. Armazenagem de dados
![Page 10: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/10.jpg)
Sobre a Data Export API
Autenticação
Conta
![Page 11: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/11.jpg)
Sobre a Data Export API
Autenticação
Conta
Relatórios
![Page 12: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/12.jpg)
Autenticação
ClientLogin (usuário e senha) Simples, mas pouca privacidade
AuthSub Proxy para web apps
oAuth Padrão aberto de autorização
![Page 13: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/13.jpg)
ClientLogin
![Page 14: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/14.jpg)
ClientLogin
curl https://www.google.com/accounts/ClientLogin -d [email protected] -d Passwd=senha -d accountType=GOOGLE -d source=intercon-v1 -d service=analytics
SID=DQAAANsBAA…Roor230g1U
LSID=DQAAAN0BAA…nkLJxeY84Q
Auth=DQAAANwBAA…BwjtFX8OF8
![Page 15: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/15.jpg)
ClientLogin
curl https://www.google.com/analytics/feeds/accounts/default?prettyprint=true --header "Authorization: GoogleLogin Auth=DQAAANwBAA…BwjtFX8OF8" --header "GData-Version: 2"
![Page 16: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/16.jpg)
ClientLogin
request =
urllib2.Request("https://www.google.com/accounts/Clien
tLogin", urllib.urlencode({"accountType": "GOOGLE",
"Email": "[email protected]", "Passwd": "senha",
"service": "analytics", "source": "intercon-v1"}))
contents = urllib2.urlopen(request).read()
auth = contents[contents.index("Auth="):]
urllib2.Request("https://www.google.com/analytics/feed
s/accounts/default", headers={"GData-Version": "2",
"Authorization": "GoogleLogin %s" % auth})
![Page 17: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/17.jpg)
AuthSub
AplicaçãoWeb
UsuárioAutorização
Acesso
Pede o tokenMostra página
autorização
Devolve token Permite acesso
Acessocom token
Dados!
![Page 18: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/18.jpg)
AuthSub
![Page 19: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/19.jpg)
oAuth
Implementado por várias bibliotecas, desktop e web apps
http://oauth.net/
http://googlecodesamples.com/oauth_playground/
![Page 20: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/20.jpg)
Account Feed
https://www.google.com/analytics/feeds/accounts/default
?start-index=1
&max-results=50
&v=2
&prettyprint=true
![Page 21: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/21.jpg)
Data Feed
https://www.google.com/analytics/feeds/data
?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
&v=2
&prettyprint=true* = obrigatório
![Page 22: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/22.jpg)
Data Feed – Table ID
ids=ga:33702370
![Page 23: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/23.jpg)
Data Feed Query Explorer
http://tinyurl.com/gdata-explorer
![Page 24: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/24.jpg)
Data Feed – Filtros / Segmentos
Métricas
== Igual
!= Diferente
> Maior
< Menor
>= Maior ou igual
<= Menor ou igual
Dimensões
== Correspondência exata
!=
=@ Contém
!@
=~ RegExp correspondente
!~, Ou; E
http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html#filters
![Page 25: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/25.jpg)
XML
<feed> (…)
<dxp:aggregates>
<dxp:metric confidenceInterval='0.0'
name='ga:visits' type='integer' value='2423'/>
</dxp:aggregates> (…)
<entry> (…)
<dxp:dimension name='ga:date' value='20111016'/>
<dxp:metric confidenceInterval='0.0'
name='ga:visits' type='integer' value='1849'/>
</entry>
</feed>
![Page 26: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/26.jpg)
Limitações
Cotas 10.000 requests / dia / conta (UA-xxxxx-yy) 10 requests / segundo / IP 4 requests simultâneos
Dimensões e métricas 7 dimensões 10 métricas Disponibilidade Combinações válidas
![Page 27: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/27.jpg)
Hackathon
http://tinyurl.com/python-googleanalytics
![Page 28: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/28.jpg)
Exemplos
https://github.com/InterconAnalytics2011/
![Page 29: Explorando a API do Google Analytics](https://reader035.fdocuments.in/reader035/viewer/2022070319/55819816d8b42a417f8b50ae/html5/thumbnails/29.jpg)
Perguntas?