问题
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors')->getTotalsForAllResults());
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors', array('dimensions' => 'ga:visitorType'))->getTotalsForAllResults());
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors', array('dimensions' => 'ga:operatingSystem'))->getTotalsForAllResults());
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors', array('dimensions' => 'ga:browser'))->getTotalsForAllResults());
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors', array('dimensions' => 'ga:networkLocation'))->getTotalsForAllResults());
print_r($service->data_ga->get('ga:78834361', '2014-01-01', 'today', 'ga:visitors', array('dimensions' => 'ga:city'))->getTotalsForAllResults());
returns
Array ( [ga:visitors] => 120 ) Array ( [ga:visitors] => 123 ) Array ( [ga:visitors] => 121 ) Array ( [ga:visitors] => 121 ) Array ( [ga:visitors] => 128 ) Array ( [ga:visitors] => 131 )
Why are the results inconsistent? Everything is the same except for the dimensions.
As requested, I have tried with "ga:visits" instead of ga:visitors. The results are consistent here. Even more confusion.
Array ( [ga:visits] => 184 ) Array ( [ga:visits] => 184 ) Array ( [ga:visits] => 184 ) Array ( [ga:visits] => 184 ) Array ( [ga:visits] => 184 ) Array ( [ga:visits] => 184 )
After some thought, is it because during that time frame, a new visitor may have revisited the site again at a later date still within the time frame, thus flagging them as a returning visitor? (for second line of code. Similar logic for the other lines?)
回答1:
If you check the diffrent reports on the GA website you will notice that they use, Visits,Visitors,Pageviews, and unique Pageviews. They are all tracked diffrently, depending on what you are trying to show its best to know the diffrence between them.
Visits vs. Visitors
Analytics measures both visits and visitors in your account. Visits represent the number of individual sessions
initiated by all the visitors
to your site. If a user is inactive on your site for 30 minutes or more, any future activity is attributed to a new session
. Users that leave your site and return within 30 minutes are counted as part of the original session
.
The initial session by a user during any given date range is considered to be an additional visit
and an additional visitor
. Any future sessions from the same user during the selected time period are counted as additional visits
, but not as additional visitors
.
Pageviews vs. Unique Pageviews
A pageview is defined as a view of a page
on your site that is being tracked by the Analytics tracking code. If a visitor clicks reload
after reaching the page, this is counted as an additional pageview
. If a user navigates
to a different page and then returns to the original
page, a second pageview
is recorded as well.
A unique pageview, as seen in the Content Overview report, aggregates pageviews that are generated by the same user during the same session
. A unique pageview represents the number of sessions during which that page was viewed one or more times.
回答2:
No_name,
one more hint -- use different end-date (ideally today - 2 days).
The data might not have been processed yet (Google claims in some cases, it might take up to 48 hours to process everything).
I have just tested something similar and I got the correct number for both visits/visitors no matter what dimension I picked.
Hope this helps.
来源:https://stackoverflow.com/questions/21325549/google-analytics-gettotalsforallresults-inconsistent-for-different-dimensions