title: How to pull visits for certain urls from GA API or GAPI?
body: <p>Basically I have a blog that I want to show the number of unique views for each post if you are logged in as an admin (I need it to calculate statistics that I can't do just looking at the regular GA admin).</p>
  
  <p>So for the input it would be series of URL paths.</p>
  
  <p>For example, if you're an admin looking at page 3 of the posts from a few days ago, and theres 10 posts per page, it would be 10 input paths.</p>
  
  <p>Like such...</p>
  
  <p><strong>input:</strong></p>
  
  <pre><code>'/hello-world/'
  '/this-demo-post/'
  '/woot/'
  </code></pre>
  
  <p>Then it would output something somewhat like this, where the array value is the number of unique visitors:</p>
  
  <pre><code>[0] =&gt; 1003,
  [1] =&gt; 140,
  [2] =&gt; 7761
  </code></pre>
  
  <p>At this point I would just output that in JSON on the page, and then use JS to make my calculations next to each post.</p>
  
  <p>The tricky part is how to get this information from GA, as its seems to just pull in ALL of the data. Even if I limit the date to 3 days old, it still pulls all the data of way older posts that are still getting a lot of traffic. It clutters the results and may even possibly 'push out' some posts I want to see if it doesn't fit within the result scope.</p>
  
  <p>I was thinking of maybe using filter regex with a lot of (this|or|that) on the 10 paths?</p>
  
  <p>Here is what I have so far.</p>
  
  <pre><code>require 'gapi.class.php';
  
  date_default_timezone_set('America/New_York');
  $dimensions = array('pagePath');
  $metrics    = array('uniquePageviews'); // visits
  $sortMetric = null;
  $filter     = null;
  $startDate  = date('Y-m-d', strtotime('-2 days'));
  $endDate    = date('Y-m-d');
  $startIndex = 1;
  $maxResults = 10000;
  
  $ga = new gapi($gaEmail, $gaPassword);
  
  $ga-&gt;requestReportData($profileId, $dimensions, $metrics, $sortMetric, $filter, $startDate, $endDate, $startIndex, $maxResults);
  </code></pre>
  
  <p><strong>Edit</strong> In retrospect, this would all be solved with a way to sort by 'first seen' and not just by total views. Is this in GAPI?</p>