title: How to get (better) demographics for fans of a Facebook page?
body: <p>I'm trying to get demographics for fans of a page on Facebook - mostly country and city, but age and gender as secondary.</p>
  
  <p>The primary way to do it is using <a href="https://developers.facebook.com/docs/reference/fql/" rel="nofollow noreferrer">FQL</a> and doing a query in the <a href="https://developers.facebook.com/docs/reference/fql/insights/" rel="nofollow noreferrer">insights</a> table. Like so:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>FB.api({
      method: 'fql.query', 
      query: "SELECT metric, value FROM insights WHERE object_id='288162265211' AND metric='page_fans_city' AND end_time=end_time_date('2011-04-16') AND period=period('lifetime')"
  }, callback);
  </code></pre>
  
  <p>The problem with this, however, is that the table <strong>returns a maximum of 19 records only</strong>, both for the country and the city stats. The response for a page I'm testing is as such:</p>
  
  <pre class="lang-js prettyprint-override"><code>[
     {
        "metric": "page_fans_city",
        "value": {
           "dallas": "12345",
           "atlanta": "12340",
           (...)
           "miami": "12300"
        }
     }
  ]
  </code></pre>
  
  <p>So I'd like to know if there's any alternative to that -- to get demographics of the current fans of a page (no snapshot necessary).</p>
  
  <p><strong>Things I've tried</strong>:</p>
  
  <ul>
  <li><p>Using LIMIT and OFFSET on the query do nothing (other than, sometimes, give me an empty list).</p></li>
  <li><p>One alternative that has been discussed in the past is <a href="https://stackoverflow.com/questions/4910782/get-all-fans-of-my-facebook-page">to use the "/members" method from the Graph API</a> (<a href="https://stackoverflow.com/questions/3560574/get-facebook-page-fans">more here</a>) to get a list of all users, and then parse through that list. That simply doesn't work - a method exists, and it may have worked in the past, but it's not valid anymore (disabled?).</p></li>
  </ul>
  
  <p>Request:</p>
  
  <pre class="lang-js prettyprint-override"><code>https://graph.facebook.com/platform/members?access_token=...
  </code></pre>
  
  <p>Response:</p>
  
  <pre class="lang-js prettyprint-override"><code>{"error":
        {
          "type":"OAuthException",
          "message":"(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http:\/\/developers.facebook.com\/docs\/reference\/fql "
        }}
  </code></pre>
  
  <ul>
  <li><p>Other solution was to do a query to the <a href="https://developers.facebook.com/docs/reference/fql/page_fan/" rel="nofollow noreferrer">page_fan</a> table <a href="https://stackoverflow.com/questions/2001281/retrieve-facebook-fan-names/2033502#2033502">and filtering by page_id</a>. This doesn't work, either; it may have worked in the past, but now it says that the page_id column is not indexable therefore it cannot be used (same error as above, which leads me to believe /members uses the same internal API that has been disabled). Page_fan query is only useful to check if individual users are fans of a page.</p></li>
  <li><p>There's also the <a href="https://developers.facebook.com/docs/reference/fql/like/" rel="nofollow noreferrer">like</a> table, but that's only useful for Facebook items (like posts, photos, links, etc), and not Facebook Pages.</p></li>
  <li><p>Going to the insights website about the Page, you can see the data in some nice graphs and tables, and download an Excel/CSV spreadsheet with the historic demographics data... however, it also limits the data to 19 entries (sometimes 20 with a few holes in there as cities trade top positions though).</p></li>
  </ul>
  
  <p>Any other hint on how to get that data? I'd either like the insights query with more results, or at least a way to get all the page fans so I could do the location query myself later (even if the page I want to get it from has almost 5 million fans... gulp).</p>