簡體   English   中英

Google Analytics(分析)報告中的分頁

[英]Pagination in google analytics report

在這里,我正在獲取下一個和上一個URL,但是當嘗試使用該URL訪問下一頁時,由於

網址= https://www.googleapis.com/analytics/v3/data/ga?ids=ga:85914642&dimensions=ga:pagePath,ga:date&metrics=ga:pageviews,ga:uniquePageviews,ga:sessionDuration,ga:bounceRate, GA:退出&排序= -ga:網頁瀏覽和過濾器= GA:網頁瀏覽%3C%3D10&開始日期= 7daysAgo&結束日期=當今啟動指數= 11&最大結果= 10

錯誤:{“錯誤”:{“錯誤”:[{“域”:“全局”,“原因”:“必需”,“消息”:“需要登錄”,“ locationType”:“標題”,“位置” :“授權”}],“代碼”:401,“消息”:“需要登錄”}}

  public  function getPaginationInfo(&$results) {
        $client = new Google_Client();
        if( isset( $_SESSION['access_token'] ) ){
            $client->setAccessToken($_SESSION['access_token']);
        } 
        // Create an authorized analytics service object.
        $analytics = new Google_Service_Analytics($client);

        // Get the first view (profile) id for the authorized user.
        $profile = $this->getFirstProfileId($analytics);

        // Get the results from the Core Reporting API and print the results.
        $this->results = $this->getResults($analytics, $profile);
        var_dump( $this->results );

        $html = <<<HTML
        <pre>
        Items per page = {$this->results->getItemsPerPage()}
        Total results  = {$this->results->getTotalResults()}
        Previous Link  = {$this->results->getPreviousLink()}
        Next Link      = {$this->results->getNextLink()}
       </pre>
HTML; 

           print $html;
        }

我也想知道當前的頁碼,那有什么功能嗎?

您需要添加accesss_token參數: &access_token=ya29.AKDF.....您應該能夠從授權的客戶端對象中獲取它:

$token = $client->getAccessToken();

然后將此令牌附加到您的下一頁鏈接。

$this->results->getPreviousLink() . "&access_token=" . $token

然后,應該對鏈接進行身份驗證。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM