How to show a Google Analytics search overview in php

How to show google analytics search overview in php ??

Google Analytics Page Shown

Visits 76

I use this function ga: organicSearches link here developers.google.com/analytics/devguides/reporting/core

I want to show this data on my new analytics website, but this feature shows me 74 visits

May I find out where I am going wrong.

Here is my code: -

$ga1 = new gapi($ga_email,$ga_password); /* We are using the 'source' dimension and the 'visits' metrics */ $dimensions = array('source'); $metrics = array('visits','organicSearches'); /* We will sort the result be desending order of visits, and hence the '-' sign before the 'visits' string */ $ga1->requestReportData($ga_profile_id, $dimensions, $metrics, '-visits', // Sort by 'visits' in descending order $filter, // Filter the data '2012-10-05', // Start Date '2012-11-04', // End Date 1, // Start Index 500 // Max results ); $gaResults = $ga1->getResults(); $i=1; foreach($gaResults as $result) { printf("%-4d %-40s %5d\n", $i++, $result->getSource(), $result->getVisits()); } echo "\n-----------------------------------------\n"; echo "Total Results : {$ga1->getTotalResults()}"; echo "getOrganicSearches:".$ga1->getOrganicSearches().'<br />'; 

Is there any other function to display this data ???

thanks

+4
source share
1 answer

Here are the parameters that I use to get the results of a regular search (without paid visits from search engines)

  $params = array( 'dimensions' => 'ga:source,ga:keyword', 'sort' => '-ga:visits,ga:source', 'filters' = 'ga:medium==organic' ); 

Note that the string is 'filters'. The value is 'ga: medium == organic' .

This will return your visits for organic traffic, you can make another call to replicate the search overview page in the Google Analytics web application.

+1
source

Source: https://habr.com/ru/post/1444558/


All Articles