Retrieve one Google analytics account on their analytic's id rather than start index (Google analytics's management 3.0) PHP client libary

StackOverflow https://stackoverflow.com/questions/12580275

Question

I am using the PHP client libary with the managment and core reporting 3.0 API. I have a system that retrives one account based on its start index. The problem behind this though is that when accounts are deleted the index for every account will change, so when I request account S and I get account M this is wrong because 5 or so accounts have been deleted. My current code for retriving accounts looks like this.

<?php
    $accounts = $service
        ->management_accounts
        ->listManagementAccounts(
            array(
                "max-results" => 1,
                "start-index" => $_SESSION['account'],
            )
        )
    ;
?>

The session variable stores a integer of the start index e.g 8.

This is some reference behind retriving accounts. https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accounts

Was it helpful?

Solution

I don't think this is possible. And maybe it is not a problem?

Why don't you get the whole list of accounts and cache it? The whole list is going to be returned as fast as one item. So overall your app is going to become faster... Most likely the whole list is not very big. I've worked with several web ad agencies and they have several hundred accounts each.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top