당신은 account_id
, property_id
및 profile_id
매개 변수를 추가해야합니다 :
temp_df = ga.read_ga(metrics,
dimensions=dimensions,
start_date=start_date,
end_date=end_date,
index_col=0,
filters=filters,
account_id=account,
property_id=property,
profile_id=profile,
start_index=start_index)
더 많은 문서는 여기에서 찾을 수 있습니다을 : 나는 패키징하는 것이 유용 발견했습니다 http://pandas.pydata.org/pandas-docs/stable/remote_data.html#remote-data-ga
내 모든 계정 정보 별도의 JSON 파일에 넣으십시오.
{
"site1": {
"acct": "123456",
"prop": "UA-123456-1",
"view": "098345983"
},
"site2": {
"acct": "987654",
"prop": "UA-987654-1",
"view": "398475987"
},
"site3": {
"acct": "456789",
"prop": "UA-456789-1",
"view": "938745876"
}
}
그런 다음 해당 계정을 다음과 같이 내 스크립트로 가져 오십시오.
import json
# p as path, gc as google analytics credentials
with open('/Path/To/Your/JSON/Goes/Here/google_analytics_accounts.json') as p:
gc = json.load(p)
p.close()
그래서 나는이 DataFrame에 Google 웹 로그 분석을 읽을 때 필요한 중 자격 증명을 사용할 수 :
temp_df = ga.read_ga(metrics,
dimensions=dimensions,
start_date=start_date,
end_date=end_date,
index_col=0,
filters=filters,
account_id=gc['site1']['acct'],
property_id=gc['site1']['prop'],
profile_id=gc['site1']['view'],
start_index=start_index)