Bhavin Radadiya
Bhavin Radadiya

Reputation: 63

GAPI: Failed to request report data. Error: "GDatainsufficientPermissionsUser does not have sufficient permissions for this profile

I'm getting following error while fetching google analytics reports

"GAPI: Failed to request report data. Error: "GDatainsufficientPermissionsUser does not have sufficient permissions for this profile."

sample code is look like below.

       <?php
define('ga_email','[email protected]');
define('ga_password','test');
define('ga_profile_id','999999999');

require 'gapi.class.php';

$ga = new gapi(ga_email,ga_password);

$ga->requestReportData(ga_profile_id,array('firefox','25.0.1'),array('pageviews','visits'));
?>
<table>
<tr>
  <th>Browser &amp; Browser Version</th>
  <th>Pageviews</th>
  <th>Visits</th>
</tr>
<?php
foreach($ga->getResults() as $result):
?>
<tr>
  <td><?php echo $result ?></td>
  <td><?php echo $result->getPageviews() ?></td>
  <td><?php echo $result->getVisits() ?></td>
</tr>
<?php
endforeach
?>
</table>

<table>
<tr>
  <th>Total Results</th>
  <td><?php echo $ga->getTotalResults() ?></td>
</tr>
<tr>
  <th>Total Pageviews</th>
  <td><?php echo $ga->getPageviews() ?>
</tr>
<tr>
  <th>Total Visits</th>
  <td><?php echo $ga->getVisits() ?></td>
</tr>
<tr>
  <th>Results Updated</th>
  <td><?php echo $ga->getUpdated() ?></td>
</tr>
</table>

Upvotes: 2

Views: 3318

Answers (2)

Rafique Mohammed
Rafique Mohammed

Reputation: 3816

Your Profile ID might be wrong! Don't mess up between Profile ID and Account ID. Both are different!

Just login to your Analytics Account and go to settings by clicking "Admin" tab and if you notice the URL Address. It will be like below

https://www.google.com/analytics/web/?hl=en#management/Settings/a46773936w11870770pxxxxxxxx/

After the letter "p" you will get the 8 digit number. That's your profile ID number.

Note : Since google interface and frameworks are changing too fast nowadays, this solution is for current interface only and i cannot guarantee that it will work on future.

Upvotes: 16

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117176

The login and password you are using doesnt have access to the profile id that you have given. Check the profile id and login and password again to be sure they are all corect. Im assuming you didnt use the ones you posted.

define('ga_email','[email protected]');
define('ga_password','test');
define('ga_profile_id','999999999');

Upvotes: 1

Related Questions