Search code examples
google-analyticszend-framework2google-apigoogle-analytics-apigoogle-analytics-firebase

How to get data from Google analytics api for different websites


Google analytics api for different websites for example:

I have 67 websites and there record in Google analytics.

Actually I want single website Top 10 links most visited, with numbers of times that link is visited and total website visits and search engine visits.

I have used GAPI but it doesn't show for specific website :

    $ga = new gapi('xxxxx@gmail.com', 'xxxxxxx');
    $dimensions = array('browser','source','region');
    $metrics = array('pageViews','visitors','visits');
    $ga->requestReportData('12312123', $dimensions, $metrics, '-visits');
    $gaResults = $ga->getResults();

if you have answer for Google analytics with zend framework2,you can answer for this Question


Solution

  • I Found Solution My Own:

    Account detail that cantain you websites:

    $ga = new gapi('xxxxx@gmail.com', 'xxxxxxx');
    

    give dimension and metrics that you want from google analytic

    $dimensions = array('browser','source','region');
    $metrics = array('pageViews','visitors','visits');
    

    Each website in google analytics have a profile_id:123456 You can see it by login in to your account.

    $ga->requestReportData(profile_id, $dimensions, $metrics, '-visits');
    

    you will retrive data for specific website