0

I am trying to work with the Google analytics API. I use following code to request data:

$ga = new gapi($ga_email,$ga_password);
$ga->requestReportData($ga_profile_id,'date',array('pageviews', 'visits'), 'date', "",$start,$end,1,1000);
$results = $ga->getResults();

Which can then be iteratd with a loop for each date

After googling I can't seem to find the answer or it is possible to get the total visits, pageviews, newvisits, uniquevisits,percentnewvisits.... for a certain timespan?

PSZ_Code
  • 1,015
  • 10
  • 29
  • You can pretty much request any Analytics data you see in the GA interface through the API. However, it can be a somewhat steep learning curve. I have instructions for PHP at [this SO question](http://stackoverflow.com/questions/13862589/google-analytics-api-v3-oauth-2). – bmorenate Nov 20 '13 at 13:51

1 Answers1

0

If you request for example. Dimesnion: Date Metrics: Pageviews,visits, UniqueVists StartDate: 20130101 endDate: 20130201

You will have a row for each date between Startdate and endDate with the values summed up for that date.

If what you want is them summed up for all the dates then You could try a dimension like Visitor type then you will only end up with 2 rows new visits and returning visits. Summed up for the time between startdate and end date.

Unfortuantly you have to select at least one dimension so you cant just get the Metrics. Using Visitor type should work then you only have to sum up the two rows that come back. Another idea would be if your start date and end date have the same Year then you could use ga:year as your dimension. Then you will only have one row summed up with all your metrics.

Edit: found something else. You could also try looking at totalsForAllResults it appears to be returned in the V3 of the core reporting client library.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449