Connecting to Google Analytics – Brighton PHP October 2013

Sunday, October 20th, 2013

This post briefly covers connecting to Google Anayltics with a service account (Google Api Console).

In order to connect to a Google Analytic (GA) profile, the following are needed

  1. A GA profile ID – the one you want to report on
  2. A service account -email address, client ID and key (download file)
  3. Ensure email address from the service account is permitted to access the google analytics profile

Sample PHP code to get the number of visitors to a site (profile ID)

Once the GA client is set-up then the following code will return hourly GA data for the given profile.

One response to “Connecting to Google Analytics – Brighton PHP October 2013”

Leave a Reply

Your email address will not be published. Required fields are marked *