2012-02-15 55 views
1

我正在研究谷歌分析,並嘗試從分析中獲取一些數據。我想要的是從分析檢索所有表ID和名稱,但真的不知道該怎麼做。我花了數小時在谷歌。有沒有辦法做到這一點 ?谷歌分析 - gapi - tableID

enter image description here

我想利用像Izlesene.com KurtlarVadisi這些所有的表 - 美孚uygulama及其ID我怎樣才能找回它們?

然後我想把它們放在我的HTML

<td width="138"><strong>Kanal Adı</strong> 
    <td width="150"><b>Kategori Adı</b></td> 
    <td width="130"><p><strong>Event Adı</strong></td> 
    <td width="145"><strong>Toplam</strong>; 

回答

5

你可以從得到的數據通過Management API

目前沒有UI來獲取我知道的這些數據。

您可以在Google API的資源管理器中使用它。

  • 轉到Google API's Explorer
  • 查找Analytics v3 API。
  • 選擇management.profiles.list方法。
  • 點擊右上角
  • 授權按鈕授權API
  • 裝滿~all
  • 單擊這兩個必填字段執行

你會得到你想要的數據的JSON提要。儘管API的瀏覽器只是一個玩具來玩API。你最好寫自己的腳本來查詢它並獲取你需要的數據。

0
function handleAllAccounts(results) {  
    if (!results.code) { 
     if (results && results.items && results.items.length) { 
      // Get the first Google Analytics account 
      var AccountIds = new Array();    
      for(var i=0 ;i<results.items.length;i++){ 
       AccountIds[i] = results.items[i].id; 
      } 
      queryAllProfiles(AccountIds,results.items.length); 
     } else { 
      console.log('No accounts found for this user.') 
     } 
    } else { 
     console.log('There was an error querying accounts: ' + results.message); 
    } 
} 

function queryAllProfiles(accountId,count) { 
    console.log('Querying Profiles.'); 
    var sel = document.getElementById('managementProfiles'); 
    var opt = null; 
    for(var i=0;i<count;i++){    
     gapi.client.analytics.management.webproperties.list({ 
      'accountId': accountId[i] 
     }).execute(function fn(results){ 
      for(var j=0;j<results.items.length;j++){    
       gapi.client.analytics.management.profiles.list({ 
        'accountId': results.items[j].accountId, 
        'webPropertyId': results.items[j].id 
       }).execute(function innertwo(profiles_results){ 
        if (!profiles_results.code) { 
         if (profiles_results && profiles_results.items && profiles_results.items.length) { 
          opt = document.createElement('option'); 
          opt.value = 'ga:'+profiles_results.items[0].id; 
          opt.innerHTML = profiles_results.items[0].name; 
          sel.appendChild(opt);              
         } 
        }    
       }) 
      } 
     })  
    } 
    sel.style.display ="block" ; 
} 


In your google analyticle javascript file put these two function these function retrive all management profiles of any google analyticle account authenticated by google