Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8030135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:40:11+00:00 2026-06-05T00:40:11+00:00

This is how Im using GAPI: $ga->requestReportData(‘van tatán tó?’, array(‘date’,’medium’),array(‘visits’), null, null, null,null, 1,

  • 0

This is how Im using GAPI:

    $ga->requestReportData('van tatán tó?', array('date','medium'),array('visits'), null, null, null,null, 1, 60000);
    foreach ($ga->getResults() as $result)
    {
        switch ($result->getMedium())
        {
            case 'referral' : $visitTypes['referral'] = $visitTypes['referral'] + $result->getVisits(); break;
            case '(none)'   : $visitTypes['direct']   = $visitTypes['direct'] + $result->getVisits(); break;
            case 'organic'  : $visitTypes['organic']  = $visitTypes['organic'] + $result->getVisits(); break;
        }
    }

now it returns good numbers, the percentages according to Google Analytics is good – but its imprecise. With this, I get [191, 336, 74] while GA returns [197, 341, 79).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:40:12+00:00Added an answer on June 5, 2026 at 12:40 am

    I see 2 problems here:

    1. “max_results” cannot be bigger than 1000, so you’re probably not receiving all the records. (There was another place where it said 10 000, but I can’t find the link anymore). Your limit is 60 000, but you’re still not getting more than the maximum allowed. You might need multiple requests in order to extract all records.
      http://code.google.com/p/gapi-google-analytics-php-interface/wiki/GAPIDocumentation

    2. you’re using 2 dimensions : ‘date’ and ‘medium’ which might generate a lot of results (see point 1 above).
      I don’t see the ‘date’ dimension being used.

    By example, for retrieving organic visits, I used:

    $dimensions = array('medium');
    $metrics    = array('visits');
    $filters    = 'medium==organic';
    $ga->requestReportData('my_profile_id',$dimensions,$metrics,'',$filters,$startDate = 'some_start_date',$endDate = 'some_end_date',$start_index=1,$max_results=1);
    echo $ga->getVisits();
    

    I used $ga->getVisits() because it retrieves the total number and I don’t have to loop through all results and sort them.

    Replace ‘my_profile_id’,’some_start_date’ and ‘some_end_date’ with your own values.

    I hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I do this using LINQ? var prop = new List<EventProposal>(); foreach (var
I am using the gapi class in a CodeIgniter website. I am using this
I want to achieve this using dynamic parameters for value expressions: <h:dataTable value=#{someBean.someValue} var=field>
I could solve this using loops, but I am trying think in vectors so
How can I do this using CSS and HTML? Bordered text surrounded by colored
When I say this using (Entities db = new Entities()) { return db.TableName.AsQueryable().ToList(); }
I see this: using (StreamWriter sw = new StreamWriter(file.txt)) { // d0 w0rk s0n
I could do this using loops, but is there a way to take two
I have compiled this using Visual Studio 2010 compiler and it has compiler error
My Code goes like this: using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream())) { string resultString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.