如何将每秒API请求限制为Google AnalyticsAPI?

时间:2016-06-16 07:53:18

标签: google-analytics polymer google-analytics-api

我使用Google AnalyticsAPI创建了一个仪表板应用程序。仪表板包含10个不同的图表。

<google-analytics-view-selector></google-analytics-view-selector>
<google-analytics-date-selector
startDate="30daysAgo"
endDate="yesterday">
</google-analytics-date-selector>

<div class="row">
<div class="six columns">
      <google-analytics-chart
        type="area"
        metrics="ga:totalEvents"
        dimensions="ga:date"
        filters="ga:eventCategory=@publication">
        <h3 class="bold">Total Publication Openings</h3>
      </google-analytics-chart>      
</div>

<div class="six columns">
       <google-analytics-chart
          type="area"
          metrics="ga:totalEvents"
          dimensions="ga:date"
          filters="ga:eventCategory=@download">
          <h3 class="bold">Downloads</h3>
        </google-analytics-chart>
</div>
</div>

<div class="row">
<div class="six columns">
      <google-analytics-chart 
        type="pie" 
        metrics="ga:sessions" 
        dimensions="ga:deviceCategory" 
        sort="-ga:sessions" 
        max-results="6"> 
        <h3 class="bold">Device Category</h3>
      </google-analytics-chart>     
</div>
<div class="six columns">
      <google-analytics-chart
        type="column"
        metrics="ga:totalEvents"
        dimensions="ga:date"
        filters="ga:eventCategory=@publication"
        segment="gaid::RqaosWyGRFevGjBRNK_WYw">
        <h3 class="bold">iOS Openings</h3>
      </google-analytics-chart>
</div>
</div>


<div class="row">
<div class="six columns">
      <google-analytics-chart
        type="column"
        metrics="ga:totalEvents"
        dimensions="ga:dayOfWeekName"
        sort="-ga:totalEvents"
        filters="ga:eventCategory=@publication">
        <h3 class="bold">Openings Per Weekday</h3>
      </google-analytics-chart>    
</div>
<div class="six columns">
      <google-analytics-chart
        type="column"
        metrics="ga:totalEvents"
        dimensions="ga:eventLabel"
        sort="-ga:totalEvents"
        max-results="5"
        filters="ga:eventCategory=@article;ga:eventLabel!@Untitled">
        <h3 class="bold">Popular Articles</h3>
      </google-analytics-chart>
</div>
</div>

<div class="row">
<div class="six columns">
        <google-analytics-chart
        type="column"
        metrics="ga:totalEvents"
        dimensions="ga:date"
        filters="ga:eventCategory=@publication"
        segment="gaid::GOz2kMV2QzGv1YwHNLybqw">
        <h3 class="bold">Desktop Openings</h3>
      </google-analytics-chart>
</div>
<div class="six columns">
      <google-analytics-chart
        type="area"
        metrics="ga:totalEvents"
        dimensions="ga:hour"
        filters="ga:eventCategory=@publication">
        <h3 class="bold">Total Openings Per Hour</h3>
      </google-analytics-chart>
</div>
</div>

<div class="row">
<div class="six columns">
       <google-analytics-chart
        type="column"
        metrics="ga:totalEvents"
        dimensions="ga:eventLabel"
        filters="ga:eventCategory=@search"
        sort="-ga:totalEvents"
        max-results="5">
        <h3 class="bold">Popular Searches</h3>
      </google-analytics-chart>
</div>
<div class="six columns">
       <google-analytics-chart
        type="bar"
        metrics="ga:totalEvents"
        max-results="5"
        dimensions="ga:eventAction"
        filters="ga:eventCategory=@download;ga:eventAction!@Unknown"
        sort="-ga:totalEvents">
        <h3 class="bold">Publication access</h3>
      </google-analytics-chart>
</div>
</div>

它工作得非常好,但每次都会抛出错误响应。错误代码是403,超过了每日配额。但是,我检查了开发人员控制台并且未超过每日使用量。谷歌还规定了每秒1个查询的限制,我认为这是违反的,因为整个仪表板同时被加载。

我可以让各个图表相互加载,或者我如何避免这个问题?

0 个答案:

没有答案