2017-02-01 6 views
2

Google 애널리틱스보고 API v4를 사용하여 여러 개의 선형 차트를 작성하려고합니다.Google 애널리틱스보고 API v4로 기기 카테고리 차트 작성

세션별로 각 장치 (데스크톱/태블릿/모바일)에 대한 행이 일별로 표시된 차트입니다.

하지만 지금은 내가 할 수있는 것은 이것이다 :

enter image description here

을 그리고 내 코드입니다 :이 질문의 답변에 따라

<div id="chart-1-container"></div> 

<script> 
gapi.analytics.ready(function() { 
    var dataChart1 = new gapi.analytics.googleCharts.DataChart({ 
     query: { 
      'ids': 'ga:XX', // <-- Replace with the ids value for your view. 
      'start-date': '7daysAgo', 
      'end-date': 'yesterday', 
      'metrics': 'ga:sessions', 
      'dimensions': 'ga:deviceCategory' 
     }, 
     chart: { 
      'container': 'chart-1-container', 
      'type': 'LINE', 
      'options': { 
       'width': '100%' 
      } 
     } 
    }); 
    dataChart1.execute(); 
}); 
</script> 
+0

더 복잡한 세그먼트 정의를 표현할 때 [마이그레이션 가이드] (https://developers.google.com/analytics/devguides/reporting/core/v4/migration)에 표시된대로 V4를 사용하여 예제를 확인하는 것이 좋습니다. 다음을 포함하는'segments' 필드를 사용합니다. [동적 세그먼트] (https://developers.google.com/analytics/devguides/reporting/core/v4/migration#segments) 개체. 예제에 표시된 것처럼 세그먼트에서 조건과 시퀀스를 결합 할 수 있습니다. 희망이 도움이됩니다! – Teyam

+0

안녕하세요, 감사합니다. 나는 그것을 점검했지만 질문을 해결할 수있는 방법을 찾지 못했다 :( – Patrick

답변

1

-Google Analytics API deviceCategory - 나는 마침내 문제를 발견 .

모바일과 같은 범주에 따라 특정 차트를 얻으려면, 데이터는 필터를하지 I와 같은 차원을 기반으로 빌드를 달성하기 위해 노력하고 있습니다 :

<div id="chart-1-container"></div> 

<script> 
    gapi.analytics.ready(function() { 
     var dataChart1 = new gapi.analytics.googleCharts.DataChart({ 
      query: { 
       'ids': 'ga:XX', // <-- Replace with the ids value for your view. 
       'start-date': '7daysAgo', 
       'end-date': 'yesterday', 
       'metrics': 'ga:sessions', 
       'dimensions': 'ga:date', 
       'filters': 'ga:deviceCategory==mobile' // <-- Filter the category here 
      }, 
      chart: { 
       'container': 'chart-1-container', 
       'type': 'LINE', 
       'options': { 
        'width': '100%' 
       } 
      } 
     }); 

     dataChart1.execute(); 

    }); 
</script> 

을 그리고 그것 뿐이다 :

enter image description here