google analytics reporting api: bebendo água direto da fonte

32
Google Analytics Reporting API Bebendo água direto da fonte @johannvivot

Upload: johann-vivot

Post on 22-Nov-2014

877 views

Category:

Technology


0 download

DESCRIPTION

Slides da palestra "Google Analytics Reporting API: Bebendo água direto da fonte" no Google Analytics User Conference Brasil 2012

TRANSCRIPT

Page 1: Google Analytics Reporting API: Bebendo água direto da fonte

Google Analytics Reporting API

Bebendo água direto da fonte

@johannvivot

Page 2: Google Analytics Reporting API: Bebendo água direto da fonte

Rotinas e padrões estabelecidos para a utilização externa de funcionalidades e serviços

de um sistema.

Como assim, API!?

Page 3: Google Analytics Reporting API: Bebendo água direto da fonte

Why!?

Page 4: Google Analytics Reporting API: Bebendo água direto da fonte

VelocidadeFlexibilidadeExtensibilidade

Page 5: Google Analytics Reporting API: Bebendo água direto da fonte

e.g.

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

Page 6: Google Analytics Reporting API: Bebendo água direto da fonte
Page 7: Google Analytics Reporting API: Bebendo água direto da fonte

Google Analytics APIs

Configuration Reporting

Management API Core Reporting API

Multi-Channel Funnels Reporting

API

Page 8: Google Analytics Reporting API: Bebendo água direto da fonte

Management API

Informações de configuração dos usuários do Google Analytics.

Page 9: Google Analytics Reporting API: Bebendo água direto da fonte

Reporting – Core Reporting API

Maior parte de core reports do Google Analytics.

Page 10: Google Analytics Reporting API: Bebendo água direto da fonte

Reporting – MCF Reporting API

Dados de Multi-Channel Funnels de um usuário.

Page 11: Google Analytics Reporting API: Bebendo água direto da fonte

Ok, mas o que vou precisar?

++ +

Page 12: Google Analytics Reporting API: Bebendo água direto da fonte

Ok, mas o que vou precisar?

Page 13: Google Analytics Reporting API: Bebendo água direto da fonte

Criando Projeto

http://code.google.com/apis/console/

Page 14: Google Analytics Reporting API: Bebendo água direto da fonte

Criando Perfil de Acesso

http://code.google.com/apis/console/

Page 15: Google Analytics Reporting API: Bebendo água direto da fonte

Escolhendo sua linguagem

http://developers.google.com/analytics/devguides/reporting/core/v3/gdataLibraries

Page 16: Google Analytics Reporting API: Bebendo água direto da fonte
Page 17: Google Analytics Reporting API: Bebendo água direto da fonte

Autorização...

<script src="https://apis.google.com/js/client.js"></script>

...

<script> function auth() { var config = { 'client_id': ‘YOUR_CLIENT_ID', 'scope': 'https://www.googleapis.com/auth/analytics.readonly' };

gapi.auth.authorize(config, function() { console.log('login complete'); console.log(gapi.auth.getToken()); }); }</script>

...<button onclick="auth();">Autorizar</button>...

https://github.com/johannvivot/gauc2012

Page 18: Google Analytics Reporting API: Bebendo água direto da fonte

Contas...

<script src="https://apis.google.com/js/client.js"></script>

...

<script> function management_accounts() { gapi.client.load('analytics', 'v3', make_management_api_accounts_call); }

function make_management_api_accounts_call() { gapi.client.analytics.management.accounts.list().execute(YOUR_HANDLER); }</script>

...

<button onclick="management_accounts();">Buscar Contas</button>

...

https://github.com/johannvivot/gauc2012

Page 19: Google Analytics Reporting API: Bebendo água direto da fonte

Web Properties...

<script src="https://apis.google.com/js/client.js"></script>

...

<script> function management_web_properties() { gapi.client.load('analytics', 'v3', make_management_api_web_properties_call); }

function make_management_api_web_properties_call() { gapi.client.analytics.management.webproperties.list({ 'accountId': ACCOUNT_ID }).execute(YOUR_HANDLER); }</script>

...

<button onclick="management_web_properties();">Buscar Web Properties</button>

...

https://github.com/johannvivot/gauc2012

Page 20: Google Analytics Reporting API: Bebendo água direto da fonte

Perfis...

<script src="https://apis.google.com/js/client.js"></script>

...

<script> function management_profiles() { gapi.client.load('analytics', 'v3', make_management_api_profiles_call); }

function make_management_api_profiles_call() { gapi.client.analytics.management.profiles.list({ 'accountId': ACCOUNT_ID, 'webPropertyId': WEB_PROPERTY }).execute(YOUR_HANDLER); }</script>

...

<button onclick="management_profiles();">Buscar Perfis</button>

...

https://github.com/johannvivot/gauc2012

Page 21: Google Analytics Reporting API: Bebendo água direto da fonte

Consulta...<script src="https://apis.google.com/js/client.js"></script>...<script> function core_reports_visits() { gapi.client.load('analytics', 'v3', make_core_reports_api_call); }

function make_core_reports_api_call() { gapi.client.analytics.data.ga.get({ 'ids': TABLE_ID, // e.g. ga:xxxxxxx 'start-date': START_DATE, 'end-date': END_DATE, 'metrics': 'ga:visits', // METRICS 'dimensions': 'ga:source', // DIMENSIONS 'sort': '-ga:visits,ga:source', // SORT 'max-results': 10000 // MAX RESULTS }).execute(YOUR_HANDLER); }</script>...<button onclick="core_reports_visits();">Buscar Visitas</button>...

https://github.com/johannvivot/gauc2012

Page 22: Google Analytics Reporting API: Bebendo água direto da fonte

Guiaids = string *

start-date = string *

end-date = string *

metrics = string *

dimensions = string

sort = string

filters = string

segment = string

start-index = integer

max-results = integer

fields = string

prettyPrint = boolean

userIp = string

quotaUser = string

access_token = string

callback = string

key = string

* Campos obrigatórios

Page 23: Google Analytics Reporting API: Bebendo água direto da fonte

Sampling

Google Analytics realiza certos cálculos on the fly. Não fique triste, use containsSampledData.

Page 24: Google Analytics Reporting API: Bebendo água direto da fonte

Brincando com Peixe Grande

Menos dimensões

Quebre por datas

Pagine seus dados

gzip

Page 25: Google Analytics Reporting API: Bebendo água direto da fonte

Dimensões e Métricas

https://developers.google.com/analytics/devguides/reporting/core/dimsmets

Page 26: Google Analytics Reporting API: Bebendo água direto da fonte

Limites da API

Geral50.000 requests por projeto por dia10 queries por segundo por IP

Core Reporting API10.000 requests por perfil por dia10 requests concorrentes por perfil

Page 27: Google Analytics Reporting API: Bebendo água direto da fonte

Dica – Data Feed Query Explorer

http://ga-dev-tools.appspot.com/explorer/

Page 28: Google Analytics Reporting API: Bebendo água direto da fonte
Page 29: Google Analytics Reporting API: Bebendo água direto da fonte
Page 30: Google Analytics Reporting API: Bebendo água direto da fonte

To infinity, and beyond!

Page 31: Google Analytics Reporting API: Bebendo água direto da fonte

Dúvidas!?

Page 32: Google Analytics Reporting API: Bebendo água direto da fonte

ObrigadoJohann Vivot

[email protected]