특정 도메인의 특정 날짜 또는 특정 도메인의 모든 날짜에 대한 이메일 측정항목을 검색할 수 있습니다.
특정 측정항목을 개선하는 방법에 관한 자세한 내용은 Gmail 사용자에게 보낸 메일이 차단되거나 스팸으로 분류되는 것을 방지하기를 참고하세요.
특정 날짜의 측정항목 검색
특정 날짜의 측정항목을 검색하려면 도메인과 날짜를 사용하여 domains.trafficStats.get()
를 호출합니다. 다음은 특정 날짜의 이메일 측정항목을 가져오는 방법을 보여주는 코드 샘플입니다.
자바
/**
* Gets the traffic stats for a domain for a specific date.
*
* @param service Authorized Gmail PostmasterTools API instance.
* @param domainName The fully qualified domain name.
* @param date The date to get the domain traffic stats. Must be in "YYYYMMDD" format.
* @return The traffic stats of the domain for this date.
* @throws IOException
*/
public static TrafficStats getTrafficStats(PostmasterTools service, String domainName, String date) throws IOException {
String query = String.format("domains/%s/trafficStats/%s", domainName, date);
TrafficStats trafficStats = service.domains().trafficStats().get(query).execute();
System.out.println(trafficStats.toPrettyString());
return trafficStats;
}
Python
"""Gets the traffic stats for a domain for a specific date.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
date The date to get the domain traffic stats. Must be in "YYYYMMDD" format.
Returns:
The traffic stats of the domain for this date.
"""
def get_traffic_stats(service, domain_name, date):
"""Gets the traffic stats for a domain for a specific date.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
date The date to get the domain traffic stats. Must be in "YYYYMMDD" format.
Returns:
The traffic stats of the domain for this date.
"""
try:
query = 'domains/%s/trafficStats/%s' %(domain_name,date)
traffic_stats = service.domains().trafficStats().get(name=query).execute();
print(traffic_stats);
return traffic_stats;
except errors.HttpError as err:
print('An error occurred: %s' % err)
요청이 성공하면 응답 본문에 TrafficStats
인스턴스가 포함됩니다.
모든 날짜의 측정항목 검색
모든 날짜의 측정항목을 검색하려면 도메인으로 domains.trafficStats.list()
를 호출합니다. 다음은 모든 날짜의 이메일 측정항목을 가져오는 방법을 보여주는 코드 샘플입니다.
자바
/**
* Lists traffic statistics for all available days.
*
* @param service Authorized Gmail PostmasterTools API instance.
* @param domainName The fully qualified domain name.
* @param pageSize The number of TrafficStats to get per request.
* @param pageToken The nextPageToken value returned from a previous List request, if any.
* @return Response message for list traffic stats request.
* @throws IOException
*/
public static ListTrafficStatsResponse listTrafficStats(PostmasterTools service, String domainName,
int pageSize,
String pageToken) throws IOException {
ListTrafficStatsResponse listTrafficStatsResponse = service.domains().trafficStats().list("domains/" + domainName)
.setPageSize(pageSize)
.setPageToken(pageToken)
.execute();
System.out.println(listTrafficStatsResponse.toPrettyString());
return null;
}
Python
"""Gets the traffic stats for a domain for a specific date.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
date The date to get the domain traffic stats. Must be in "YYYYMMDD" format.
page_size The number of TrafficStats to get per request.
page_token The nextPageToken value returned from a previous List request, if any.
Returns:
The traffic stats of the domain for this date.
"""
def list_traffic_stats(service, domain_name, date, page_size, page_token):
"""Gets the traffic stats for a domain for a specific date.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
date The date to get the domain traffic stats. Must be in "YYYYMMDD" format.
page_size The number of TrafficStats to get per request.
page_token The nextPageToken value returned from a previous List request, if any.
Returns:
The traffic stats of the domain for this date.
"""
try:
query = 'domains/' + domain_name
list_traffic_stats_response = service.domains().trafficStats().list(parent=query, pageSize=page_size, pageToken=page_token).execute();
print(list_traffic_stats_response);
return list_traffic_stats_response;
except errors.HttpError as err:
print('An error occurred: %s' % err)
if __name__ == '__main__':
main()
성공하면 응답 본문에 다음과 같은 구조의 TrafficStats
페이지가 생성된 배열이 포함됩니다.
{
"trafficStats": [
{
object (TrafficStats)
}
],
"nextPageToken": string
}