Currently I've only build in support for Google Analytics but you could easily modify it to support other Google APIs. If you add further support please feel free to help by contributing to this project. If you have any questions or comments you can email me at [email protected].
- Go to: Google APIs
- Create a Client ID of type Service account
- Download the newly created p12 file, title it googlekey.p12 and place it into the main "Config" folder.
- The new service account will also have:
- Client ID which is GOOGLE_CLIENT_ID
- Email Address which is GOOGLE_SERVICE_ACCOUNT_NAME
- You'll also need the GOOGLE_ANALYTICS_ACCOUNT_ID this can be found within the Analytics account
- Navigate to the profile you want to query
- Find the Profile ID on the profile settings page
- You may get an error that the account does not have an analytics account, you need to add the GOOGLE_SERVICE_ACCOUNT_NAME as a user within your analytics account so we can get access to the profile
- More information can be found at Google API Reference Documentation
-
Add the following code to your local bootstrap with the information gathered from the above steps:
define('GOOGLE_ANALYTICS_ACCOUNT_ID', 'XXXXXXX'); define('GOOGLE_CLIENT_ID', 'Client ID'); define('GOOGLE_SERVICE_ACCOUNT_NAME', 'Email Address');
-
You can then add shell scripts to periodically (on a cronjob) cache data from google analytics via shell command. An example can be seen here
Console/Command/AnalyticsShell.php.example
, demonstrating how you might update a model view count based on it's path/slug.