$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits",
array(
"dimensions" => "ga:keyword",
'sort' => '-ga:visits',
"filters" => "ga:medium==organic"
)
);
It would seem
ga:medium
ge:visits
does the trick,
(none)
is "direct traffic
organic
+ cpc
is search engine
referral
is non search engine link
then, the sum of everything else is "campaign"
Keywords from Search Engines
$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits",
array(
"dimensions" => "ga:keyword",
'sort' => '-ga:visits'
)
);
$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits",
array(
"dimensions" => "ga:keyword",
'sort' => '-ga:visits',
"filters" => "ga:medium==organic"
)
);
Search Engines
$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits",
array(
"dimensions" => "ga:source",
'sort' => '-ga:visits',
"filters" => "ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc"
)
);
Top Landing Pages
$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits",
array(
"dimensions" => "ga:landingPagePath",
'sort' => '-ga:visits'
)
);
Search referrer details
$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits,ga:bounces,ga:visitors,ga:newVisits,ga:timeOnSite,ga:entrances,ga:pageviews,ga:timeOnPage,ga:exits",
array(
"dimensions" => "ga:referralPath",
'sort' => '-ga:visits',
'segment' => 'gaid::-8',
"filters" => "ga:source==".urlencode($referrer)
)
);
Get segments list
$segments = $analytics->management_segments->listManagementSegments();
Google_Segments Object
(
[username] => 623644681999-dmg2maloc8obsuiiru0k0fv8no0bouv2@developer.gserviceaccount.com
[kind] => analytics#segments
[__itemsType:protected] => Google_Segment
[__itemsDataType:protected] => array
[items] => Array
(
[0] => Google_Segment Object
(
[definition] =>
[kind] => analytics#segment
[segmentId] => gaid::-1
[created] =>
[updated] =>
[id] => -1
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-1
[name] => All Visits
)
[1] => Google_Segment Object
(
[definition] => ga:visitorType==New Visitor
[kind] => analytics#segment
[segmentId] => gaid::-2
[created] =>
[updated] =>
[id] => -2
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-2
[name] => New Visitors
)
[2] => Google_Segment Object
(
[definition] => ga:visitorType==Returning Visitor
[kind] => analytics#segment
[segmentId] => gaid::-3
[created] =>
[updated] =>
[id] => -3
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-3
[name] => Returning Visitors
)
[3] => Google_Segment Object
(
[definition] => ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc
[kind] => analytics#segment
[segmentId] => gaid::-4
[created] =>
[updated] =>
[id] => -4
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-4
[name] => Paid Search Traffic
)
[4] => Google_Segment Object
(
[definition] => ga:medium==organic
[kind] => analytics#segment
[segmentId] => gaid::-5
[created] =>
[updated] =>
[id] => -5
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-5
[name] => Non-paid Search Traffic
)
[5] => Google_Segment Object
(
[definition] => ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc
[kind] => analytics#segment
[segmentId] => gaid::-6
[created] =>
[updated] =>
[id] => -6
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-6
[name] => Search Traffic
)
[6] => Google_Segment Object
(
[definition] => ga:medium==(none)
[kind] => analytics#segment
[segmentId] => gaid::-7
[created] =>
[updated] =>
[id] => -7
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-7
[name] => Direct Traffic
)
[7] => Google_Segment Object
(
[definition] => ga:medium==referral
[kind] => analytics#segment
[segmentId] => gaid::-8
[created] =>
[updated] =>
[id] => -8
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-8
[name] => Referral Traffic
)
[8] => Google_Segment Object
(
[definition] => ga:goalCompletionsAll>0
[kind] => analytics#segment
[segmentId] => gaid::-9
[created] =>
[updated] =>
[id] => -9
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-9
[name] => Visits with Conversions
)
[9] => Google_Segment Object
(
[definition] => ga:transactions>0
[kind] => analytics#segment
[segmentId] => gaid::-10
[created] =>
[updated] =>
[id] => -10
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-10
[name] => Visits with Transactions
)
[10] => Google_Segment Object
(
[definition] => ga:isMobile==Yes
[kind] => analytics#segment
[segmentId] => gaid::-11
[created] =>
[updated] =>
[id] => -11
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-11
[name] => Mobile Traffic
)
[11] => Google_Segment Object
(
[definition] => ga:bounces==0
[kind] => analytics#segment
[segmentId] => gaid::-12
[created] =>
[updated] =>
[id] => -12
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-12
[name] => Non-bounce Visits
)
[12] => Google_Segment Object
(
[definition] => ga:isTablet==Yes
[kind] => analytics#segment
[segmentId] => gaid::-13
[created] =>
[updated] =>
[id] => -13
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-13
[name] => Tablet traffic
)
)
[itemsPerPage] => 1000
[previousLink] =>
[startIndex] => 1
[nextLink] =>
[totalResults] => 13
)