Google Analytics Reporting API: Bebendo água direto da fonte

Post on 22-Nov-2014

877 views 0 download

description

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

Transcript of Google Analytics Reporting API: Bebendo água direto da fonte

Google Analytics Reporting API

Bebendo água direto da fonte

@johannvivot

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

de um sistema.

Como assim, API!?

Why!?

VelocidadeFlexibilidadeExtensibilidade

e.g.

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

Google Analytics APIs

Configuration Reporting

Management API Core Reporting API

Multi-Channel Funnels Reporting

API

Management API

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

Reporting – Core Reporting API

Maior parte de core reports do Google Analytics.

Reporting – MCF Reporting API

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

Ok, mas o que vou precisar?

++ +

Ok, mas o que vou precisar?

Criando Projeto

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

Criando Perfil de Acesso

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

Escolhendo sua linguagem

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

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

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

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

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

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

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

Sampling

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

Brincando com Peixe Grande

Menos dimensões

Quebre por datas

Pagine seus dados

gzip

Dimensões e Métricas

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

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

Dica – Data Feed Query Explorer

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

To infinity, and beyond!

Dúvidas!?

ObrigadoJohann Vivot

johannvivot@gmail.com