1
Fork 0

Get page views and visitors

This commit is contained in:
Jake Howard 2023-05-04 09:19:21 +01:00
parent 3bba01a3dd
commit d7b66de563
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -26,7 +26,8 @@ def get_pages(site_id: str, session: requests.Session):
"period": "custom",
"date": "2000-01-01," + today,
"property": "event:page",
"page": page_num
"page": page_num,
"metrics": "pageviews,visitors"
})
response.raise_for_status()
@ -44,7 +45,7 @@ def main():
session.headers["Authorization"] = "Bearer " + os.environ["PLAUSIBLE_API_TOKEN"]
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):
writer.writerow(page)