Get page views and visitors
This commit is contained in:
parent
3bba01a3dd
commit
d7b66de563
1 changed files with 3 additions and 2 deletions
|
@ -26,7 +26,8 @@ def get_pages(site_id: str, session: requests.Session):
|
||||||
"period": "custom",
|
"period": "custom",
|
||||||
"date": "2000-01-01," + today,
|
"date": "2000-01-01," + today,
|
||||||
"property": "event:page",
|
"property": "event:page",
|
||||||
"page": page_num
|
"page": page_num,
|
||||||
|
"metrics": "pageviews,visitors"
|
||||||
})
|
})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ def main():
|
||||||
session.headers["Authorization"] = "Bearer " + os.environ["PLAUSIBLE_API_TOKEN"]
|
session.headers["Authorization"] = "Bearer " + os.environ["PLAUSIBLE_API_TOKEN"]
|
||||||
|
|
||||||
with open(f"report-{args.site_id}.csv", "w") as f:
|
with open(f"report-{args.site_id}.csv", "w") as f:
|
||||||
writer = csv.DictWriter(f, fieldnames=["page", "visitors"])
|
writer = csv.DictWriter(f, fieldnames=["page", "visitors", "pageviews"])
|
||||||
|
|
||||||
for page in get_pages(args.site_id, session):
|
for page in get_pages(args.site_id, session):
|
||||||
writer.writerow(page)
|
writer.writerow(page)
|
||||||
|
|
Loading…
Reference in a new issue