From d7b66de563a3ec2f3b84eed5b98481cb7e215903 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2023 09:19:21 +0100 Subject: [PATCH] Get page views and visitors --- report.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/report.py b/report.py index 3f822a8..49fe58b 100644 --- a/report.py +++ b/report.py @@ -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)