title: How to filter by URI path in Google Analytics API
body: <p>I would like to get some Google Analytics data (number of page views) (API V3) filtered with <code>ga:pagePath</code>. </p>
  
  <p>Firstly I connect to API with the following code: </p>
  
  <pre><code>$token = "some token";
  
  $client = new Google_Client();
  $client-&gt;setApplicationName("***");
  $client-&gt;setClientId($client_id);
  $client-&gt;setClientSecret($client_secret);
  $client-&gt;setRedirectUri($redirect_uri);
  $client-&gt;setDeveloperKey($developer_key);
  $client-&gt;setScopes(array("https://www.googleapis.com/auth/analytics.readonly"));
  $client-&gt;setApprovalPrompt('force');
  $client-&gt;setAccessType('offline');
  $client-&gt;setAccessToken($token);
  </code></pre>
  
  <p>Then I get all accounts with their respective profiles (views):</p>
  
  <pre><code>$service = new Google_Service_Analytics($client);               
  $accounts = $service-&gt;management_accountSummaries-&gt;listManagementAccountSummaries();
  
  $profiles = new stdClass();
  
  foreach ($accounts-&gt;getItems() as $item) {
  
      foreach($item-&gt;getWebProperties() as $wp) {  
          $views = $wp-&gt;getProfiles();
  
          if (!is_null($views)) {
  
              foreach($wp-&gt;getProfiles() as $view) {
                  $profiles-&gt;{$view['id']} = $view['name'];
              }
          }
      }
  }
  </code></pre>
  
  <p>After I got all profiles (views) I get the data:</p>
  
  <pre><code>$path = "/example-path/path-example";
  $host = "www.example.com";
  
  $optParams = array(
      'dimensions' =&gt; 'ga:pagePath,ga:source,ga:keyword',
      'sort' =&gt; '-ga:sessions,ga:source',
      'filters' =&gt; 'ga:medium==organic,ga:pagePath=='.$path.',ga:hostname=='.$host,
      'max-results' =&gt; '25'
  );
  
  $totalSessions = 0;
  
  $today = date('Y-m-d', time());
  $monthbefore = date('Y-m-d', (time() - (30 * 24 * 60 * 60)));
  
  foreach ($profiles as $profile_id =&gt; $profile) {
      $data = $service-&gt;data_ga-&gt;get(
                  "ga:".$profile_id,
                  $monthbefore,
                  $today,
                  'ga:sessions',
                  $optParams
               );
  
      $totalSessions += intval($data-&gt;totalsForAllResults['ga:sessions']);
  }
  
  if (!isset($analytics_data)) {
      $analytics_data = new stdClass();
  }
  
  if (!isset($analytics_data-&gt;$ii)) {
      $analytics_data-&gt;$ii = new stdClass();
  }
  
  $analytics_data-&gt;$ii-&gt;{'total_page_views'} = $totalSessions;
  </code></pre>
  
  <p>And now I get the data. But the problem is I get the total number of page views for the whole website while I need the number of page views for a page with the particular path "/example-path/path-example". I cannot figure out where exactly I am missing. Thanks in advance.</p>