Hello @flaviese,
The simple answer is that what the API returns will not match what is visible in the web interface of the GA. The difference is in sampled data vs. unsampled data which you can read about here: https://support.google.com/analytics/answer/1042498?hl=en
For testing what the API returns you can use this tool: https://ga-dev-tools.appspot.com/explorer/
The GA data is being read here: https://github.com/presslabs/toplytics/blob/master/src/components/Backend.php#L834
We’re using v1 branch of https://github.com/googleapis/google-api-php-client for this using the data_ga and the ga:pagePath dimension.
Here are more details about filters and segments: https://support.google.com/analytics/answer/7331978?hl=en
Best regards,
~Presslabs Team
Hi, thank you for the reply. Using the query explorer tool and trying to simulate a filtered view such as we were using google analytics dashboard itself, can you tell me which data to put into the fields having for example to simulate the query of a toplytics widget with the following settings:
– weekly top
– allowed post types: post
I did a test with:
start date: 2020-03-26
end-date: 2020-04-01
metrics: ga:pageviews
dimensions: ga:pageTitle ga:dataSource
…but i don’t still find any relation with /wp-json/toplytics/results plugin’s Json Endpoint Path file.
My aim is to show to my customer how to simulate a toplytics query directly in the Google analytics dashboard to find some correspondence with what the plugin shows…
Regards,
Flavio
Hello @flaviese
Thank you for your patience.
The settings are as follows for the last month view by default for example:
– Account, Property, Views and IDs will get set automatically once authorized;
– start-date: 30daysAgo
– end-date: yesterday
– metrics: ga:pageviews
– dimensions: ga:pagepath
– sort: -ga:pageviews
– max-results: 20
This will return top 20 pages by the number of page views. After this Toplytics will match these URLs to your site and also filter by post type so you are only left with actual posts/
Best regards,
~Presslabs Team
great!
thank you very much 🙂
Flavio