2017-04-13 2 views
0

私はGoogleアナリティクスのレポートを自分のWebページに埋め込みたいと考えていますが、これまではga-dev-tools.appspot.comのチュートリアル/ドキュメントに従っていました。これは今私の結果です... enter image description here 問題は、私はすべてのプロパティ(画像に三角形のオプション)を表示するwan'tと私は現在のページのプロパティだけを表示するwan't 1つのプロパティだけを表示する方法を調べる必要があります。google analytics APIで1つのプロパティのみを選択できるようにする方法

だからこれは私のコードは

<h2>Sessions</h2> 
<p>Last 30 days</p> 
<div id="chart-container"></div> 
<div id="view-selector-container"></div> 

<script> 
    gapi.analytics.ready(function() { 
     /** 
     * Authorize the user immediately if the user has already granted access. 
     * If no access has been created, render an authorize button inside the 
     * element with the ID "embed-api-auth-container". 
     */ 
     gapi.analytics.auth.authorize({ 
      container: 'embed-api-auth-container', 
      clientid: '<MyClientId>' 
     }); 

     /** 
     * Create a new ViewSelector instance to be rendered inside of an 
     * element with the id "view-selector-container". 
     */ 
     var viewSelector = new gapi.analytics.ViewSelector({ 
      container: 'view-selector-container', 
     }); 

     // Render the view selector to the page. 
     viewSelector.execute(); 

     /** 
     * Create a new DataChart instance with the given query parameters 
     * and Google chart options. It will be rendered inside an element 
     * with the id "chart-container". 
     */ 
     var dataChart = new gapi.analytics.googleCharts.DataChart({ 
      query: { 
       metrics: 'ga:sessions', 
       dimensions: 'ga:date', 
       'start-date': '30daysAgo', 
       'end-date': 'yesterday' 
      }, 
      chart: { 
       container: 'chart-container', 
       type: 'LINE', 
       options: { 
        width: '100%' 
       } 
      } 
     }); 

     /** 
     * Render the dataChart on the page whenever a new view is selected. 
     */ 
     viewSelector.on('change', function(ids) { 
      dataChart.set({query: {ids: ids}}).execute(); 
     }); 
    }); 
</script> 

だから、男はそれが唯一のプロパティのデータを取得/表示するには、どこかのparamを追加することが可能である今のところありますか? 追加情報が必要な場合は、お知らせください。ありがとうございます

答えて

1

ご使用の場合によって異なります。ユーザが関連するビューを見つけるためにリストを通らないように便利であることを意味する場合、関連するIDのみがハードコードされている選択フィールドコンボを手動で構築することができます(そして、dataChart setメソッドviewSelectorからの出力と同じようにクエリを実行する前に)。

何らかの種類のセキュリティーメカニズムを意味する場合は、(ユーザーはいずれの場合もプロパティーにアクセスできますが、これはブラウザーで呼び出しを操作できるJavascriptです)。

+0

スーパー!先端のためのThx! –

関連する問題