I am currently getting my data like this:
$result = Analytics::performQuery(
Period::days(7),
'ga:pageviews',
[
'dimensions' => 'ga:pagePath',
'max-results' => $maxResults,
'sort' => '-ga:pageviews',
'filters' => 'ga:pagePath=~/blog*'
]
);
The response delivers multiple pages with the same slug like:
/blogs/article1
/blogs/article1?ref=homepage
and so on.
In order to get all the pageviews I currently explode the URL at the get parameter then in a foreach loop I get the total pageviews like this:
$article = Analytics::performQuery(
Period::days(7),
'ga:pageviews',
[
'dimensions' => 'ga:pagePath',
'sort' => '-ga:pageviews',
'filters' => 'ga:pagePath=='.$result['url']
]
);
then I get the total pageviews with article['totalsForAllResults']['ga:pageviews']
This obviously ends up making many google requests, which have a daily limit. Is there a way to get the total pageviews of one URL plus all the URLs that have the same name and get parameters attached?