简体   繁体   English

从Google Analytics(分析)获取所有数据

[英]Get all data from Google Analytics

I am new to Google Analytics (started with it 1 week ago) and I am trying to pull all the data available for a specific day and insert it into a mysql database. 我是Google Analytics(分析)的新手(从1周前开始),我想提取特定日期的所有可用数据并将其插入mysql数据库。 I want to get everything that is available for that specific day. 我想获取当天特定的一切。

$optParams = array( //OPTINAL SETTINGS
          'dimensions' => 'ga:campaign, ga:medium, ga:source, ga:adContent, ga:keyword', //A comma-separated list of Multi-Channel Funnels dimensions. E.g., 'mcf:source,mcf:medium'. (string)
          'metrics' => 'ga:adClicks, ga:adCost, ga:goalValueAll, ga:goal1Completions, ga:goal6Completions',
          'max-results' => 10000,
          'samplingLevel' => 'HIGHER_PRECISION'
          ); //The maximum number of entries to include in this feed. (integer)

       $requestedInfo = '';
       $requestedInfo .= 'ga:sessions';


$data = $analytics->data_ga->get('ga:XXXXX', '2015-04-07', '2015-04-07', $requestedInfo, $optParams);

This code will get me far less results than I can get on the platform when combining two dimensions (primary dimension, secondary dimension). 与组合两个维度(主要维度,次要维度)时相比,此代码给我带来的结果要比在平台上获得的结果少得多。 I get thousands of records for specific combinations and with my code I get something in the range of 600. I would like to know how I can format my query to get all the data available (all the records available) and then sort it however I want to. 我得到了成千上万条针对特定组合的记录,并通过代码获得了600范围内的信息。我想知道如何格式化查询以获取所有可用数据(所有可用记录),然后对其进行排序想要。

Also, should I create a different MySQL table for each campaign, medium etc or one that include all is enough? 另外,我是否应该为每个广告系列,媒介等或包含所有内容的一个表创建一个不同的MySQL表?

A few things to note: 注意事项:

First of all you aren't going to be able to get ALL of your data . 首先,您aren't going to be able to get ALL of your data You are limited to 10000 requests against the api each day per profile id (view). 每个配置文件ID(视图)每天最多限制10000个针对api的api请求。 With a max number of rows of 10000. It will be very hard for you to get ALL your data even if its a small site and the data probably wont relate back to itself correctly. 最大行数为10000。即使您的站点很小,而且数据可能不会正确地与其自身关联,您也很难获得所有数据。

Second you are limited to 8 dimensions even if you use the date as your primary key the data that is returned will not relate back to itself correctly because the data is calculated based upon the initial request that you made. 其次,即使您使用日期作为主键,您也被限制在8个维度上,因为返回的数据将根据您的初始请求进行计算,因此返回的数据will not relate back to itself correctly

Third large queries are going to sample data even if you set it to higher_percission. 第三个大的查询 ,即使你把它设置为higher_percission采样数据。

Your issue: 您的问题:

As to why your returning less results. 至于为什么您返回的结果较少。 I think you should try using the query explorer to play around with your requests a little. 我认为您应该尝试使用查询浏览器来处理您的请求。 ga:keyword if its not set then it wont return anything in some cases. ga:keyword如果未设置,则在某些情况下不会返回任何内容。 Its your query that is reducing the number of rows. 它是减少行数的查询。

You need to think of the Google Analytics data as a multidimensional database instead of a relational database. 您需要将Google Analytics(分析)数据视为multidimensional database而不是关系数据库。 There is a difference. 它们是有区别的。

Big Query 大查询

A better approach would be to have Google extract your Data for you into Big Query this will allow you to do what ever you want with it. 更好的方法是让Google为您提取您的数据到Big Query中,这将使您可以做任何您想做的事情。 The limitations of the API do not apply to Google Analytics Data in Big query. API的限制不适用于Big查询中的Google Analytics(分析)数据。 This requires that you have a Premium Google Analytics account 这要求您拥有一个高级Google Analytics(分析)帐户

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM