2010-01-11 3 views
0

아래 코드는 Google 웹 로그 분석에서 사용자 계정 검색을위한 코드입니다. 내 질문은 코드 대신 ga:AccountNamega:ProfileId 대신 교체 할 코드입니다. 사이트에 로그인 한 방문자를 찾으려면 다음을 수행하십시오.Google 웹 로그 분석 관련 질문

/* 
* Retrieve 50 accounts with profile names, profile IDs, table IDs 
* for the authenticated user 
*/ 

// Create the analytics service object 
var analyticsService = 
    new google.gdata.analytics.AnalyticsService('iSample_acctSample_v1.0'); 

// The feed URI that is used for retrieving the analytics accounts 
var feedUri = 
    'https://www.google.com/analytics/feeds/accounts/default?max-results=50'; 

// callback method to be invoked when getAccountFeed() returns data 
var callback = function(result) { 

    // An array of analytics feed entries 
    var entries = result.feed.entry; 

    // create an HTML Table using an array of elements 
    var outputTable = ['<table>']; 
    outputTable.push('<tr>', 
    '<th>Account Name</th>', 
    '<th>Profile Name</th>', 
    '<th>Profile Id</th>', 
    '<th>Table Id</th></tr>'); 

    // Iterate through the feed entries and add the data as table rows 
    for (var i = 0; i < entries.length; i++) { 
    var entry = entries[i]; 

    // add a row in the HTML Table array for each value 
    var row = [ 
     entry.getPropertyValue('ga:AccountName'), 
     entry.getTitle().getText(), 
     entry.getPropertyValue('ga:ProfileId'), 
     entry.getTableId().getValue() 
    ].join('</td><td>'); 
    outputTable.push('<tr><td>', row, '</td></tr>'); 
    } 
    outputTable.push('</table>'); 

    // print the generated table 
    PRINT(outputTable.join('')); 
} 

// Error handler 
var handleError = function(error) { 
    PRINT(error); 
} 

// Submit the request using the analytics service object 
analyticsService.getAccountFeed(feedUri, callback, handleError); 
+0

이 부분에 ..? – Hulk

답변

1

Google 웹 로그 분석 데이터 피드 검색어 탐색기 Here is the link을 사용하여 API 요청을 작성할 수 있습니다. 웹 로그 분석 데이터와 연결된 Google 계정으로 인증하면 쿼리 할 프로필을 선택하고 연결된 프로필 ID를 볼 수 있습니다.

계정 ID는 애널리틱스 추적 코드에서 'UA-'다음에 -1 (또는 [any any]) 접미사 앞에 오는 번호입니다. 메모리에서 저는 AccountName이 Google 계정과 연결된 이메일 주소라고 생각합니다 (@ gmail.com 일 수도 있지만 그럴 필요는 없습니다).

관련 문제