Modified to collect visit instead of visitors.
--- a/ckanext/ga_report/controller.py
+++ b/ckanext/ga_report/controller.py
@@ -255,9 +255,7 @@
log.warning('Could not find package "%s"', package_name)
else:
ds = {}
- for entry in q:
- if len(ds) >= count:
- break
+ for entry in q.limit(count):
package_name = entry.url[len('/dataset/'):]
p = model.Package.get(package_name)
if p:
--- a/ckanext/ga_report/download_analytics.py
+++ b/ckanext/ga_report/download_analytics.py
@@ -147,7 +147,7 @@
start_date = start_date.strftime('%Y-%m-%d')
end_date = end_date.strftime('%Y-%m-%d')
query = 'ga:pagePath=%s$' % path
- metrics = 'ga:uniquePageviews, ga:visitors'
+ metrics = 'ga:uniquePageviews, ga:visits'
sort = '-ga:uniquePageviews'
# Supported query params at
@@ -209,7 +209,7 @@
results = self.service.data().ga().get(
ids='ga:' + self.profile_id,
start_date=start_date,
- metrics='ga:pageviewsPerVisit,ga:avgTimeOnSite,ga:percentNewVisits,ga:visitors',
+ metrics='ga:pageviewsPerVisit,ga:avgTimeOnSite,ga:percentNewVisits,ga:visits',
max_results=10000,
end_date=end_date).execute()
result_data = results.get('rows')