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 6805679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:36:58+00:00 2026-05-26T19:36:58+00:00

I am trying to request (using the gapi source code) the referred from link

  • 0

I am trying to request (using the gapi source code) the referred from link to the users website. so for example if they clicked through from facebook, and how many referrals came through.

My gapi code to link for page view by date currently looks like this.

$ga = new gapi(ga_email,ga_password);
$filter = 'country == United Kingdom && browser == Firefox || browser == Chrome';
$ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pageviews','visits'),'-visits',$filter,  $start_date=$date, $end_date=$date);

and is echoed in the page with

<?php echo $ga->getVisits() ?>

How do i get the filter to display the refered from in a list nd echo it through the page?

  • 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-05-26T19:36:59+00:00Added an answer on May 26, 2026 at 7:36 pm

    Here’s my script that sole purpose is to get referral URL and total pageviews and visits. I think that’s what you want.

    <?php
    define('ga_email','username@email.com');
    define('ga_password','password');
    define('ga_profile_id','profile_id');
    
    require 'gapi.class.php';
    
    $ga = new gapi(ga_email,ga_password);
    
    $filter = 'medium==referral && referralPath != /';
    
    /***  // << add '/' to uncomment
    $date_start = '2011-11-01';
    $date_end = '2011-11-13';
    //**/$date_start = $date_end = null;
    
    $ga->requestReportData(
        ga_profile_id,
        array('source','referralPath'),//what field you are looking for
        array('pageviews','visits'),//what metric you want to calculate
        '-visits',//sort order, prefix - means descending
        $filter,//filter query
        $date_start,//yyyy-mm-dd or null
        $date_end,//yyyy-mm-dd or null
        1,//offset lookup
        100);//max result
    ?>
    <table>
    <tr>
      <th>Referral URL</th>
      <th>Pageviews</th>
      <th>Visits</th>
    </tr>
    <?php
    foreach($ga->getResults() as $result):
    ?>
    <tr>
      <td><?php echo $result->getSource() . $result->getReferralPath() ?></td>
      <td><?php echo $result->getPageviews() ?></td>
      <td><?php echo $result->getVisits() ?></td>
    </tr>
    <?php
    endforeach
    ?>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I'm trying to POST a http request using ajax, but getting a response from
I'm trying to send an ajax request using jquery. From the tutorial, I try
I'm trying to parse some JSON coming from an AJAX request using jQuery. Basically,
I've got a problem trying to send a request using QNetworkAccessManager from a QObject
I'm trying to perform a simple html request using jquery with the code below.
I am trying to serve a JavaScript response from a JavaScript request using PHP.
I'm trying to make a request using dojo.xhrGet to grab some XML data from
Im trying to request https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=[http://www.my-website.dk/]&key=[my-key] using urlfetch from app engine but it's not working.
I'm trying to send a SOAP request using SOAPpy as the client. I've found

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.