Getting started with Google Analytics API
I'm a complete newbie with API's. I'm a WordPress theme and plugin developer by trade and have never needed to touch API's before. I now need to do this, and I'm struggling to get started with the Google Analytics API. I'm working on a WordPress plugin (can be installed on multiple sites) that needs to authenticate the site owner with the Google Analytics API, and then ultimately pull information from Google analytics to be displayed on the website.
I've been searching around for a starting point for a while now, and I think I need to be looking into the 'Embed API', but not 100% sure. I have found the following:
https://developers.google.com/analytics/devguides/reporting/embed/v1/getting-started
Am I correct in thinking that I need to look into the 'Embed API', in order to achieve the desired effect for the plugin I am working on? Or do I need to be looking into the 'Hello Analytics API'? Or am I going in completely the wrong direction?
Based on https://ga-dev-tools.appspot.com/embed-api/basic-dashboard/, I THINK I need to be looking into the Embed API, but I could just do with some clarification.
Any help or advice would be hugely appreciated, thanks :)
You are more likely looking for the Core Reporting API, which allows you to retrieve data from GA via serverside code.
The Embed API is a Javascript client for the Reporting API, but it (usually) requires the user to log in to their Google Account in their browser and then displays data from the GA properties they have access to. The nice thing about the Embed API is that visualization is built in; with the other APIs (Core Reporting and Realtime) you have to do your own graphs.
If you want to authenticate access with data that has been entered via user data that is stored in your Wordpress backend, and if you want to store data from GA within your own database, then the Core Reporting API is likely the better pick. Since the authentication is handled via server side code, not via the browser, you can also display data from accounts the users does not have access to themselves.
链接地址: http://www.djcxy.com/p/35878.html