How can I retrieve the number of fans my Facebook page had on a given day?

Learn how can i retrieve the number of fans my facebook page had on a given day? with practical examples, diagrams, and best practices. Covers facebook, facebook-fql development techniques with vis...

Retrieving Historical Facebook Page Fan Counts

Hero image for How can I retrieve the number of fans my Facebook page had on a given day?

Learn how to access and analyze historical fan data for your Facebook page, understanding the limitations and available tools.

Understanding the growth of your Facebook page is crucial for marketing analysis and strategy. While Facebook's Graph API provides extensive data, retrieving historical fan counts for a specific past date can be a bit nuanced. This article will guide you through the methods available, focusing on the Facebook Graph API and its limitations, and how to best approach this data retrieval.

Understanding Facebook Page Insights and the Graph API

Facebook provides detailed analytics through Page Insights, accessible directly from your page's admin panel. This interface often offers a visual representation of fan growth over various periods. For programmatic access, the Facebook Graph API is the primary tool. However, it's important to note that the Graph API's capabilities for historical data are subject to specific endpoints and permissions.

flowchart TD
    A[Facebook Page] --> B{Page Insights (UI)}
    A --> C{Facebook Graph API}
    C --> D[Access Token]
    D --> E[Page ID]
    E --> F{Metrics Endpoint}
    F --> G{"page_fans_lifetime" metric}
    G --> H[Daily Fan Count Data]

Flowchart of accessing Facebook Page Fan Data

Accessing Daily Fan Counts via Graph API

The most direct way to get historical fan data programmatically is by querying the page_fans_lifetime metric through the Graph API's Insights endpoint. This metric provides the total number of fans at the end of each day. You'll need a Page Access Token with pages_read_engagement and pages_show_list permissions.

GET /v18.0/{page-id}/insights?metric=page_fans_lifetime&period=day&since={start-date}&until={end-date}&access_token={your-page-access-token}

Example Graph API request for daily fan counts

Replace {page-id} with your Facebook Page ID, {start-date} and {end-date} with Unix timestamps or YYYY-MM-DD formatted dates, and {your-page-access-token} with your valid Page Access Token. The period=day parameter is crucial for getting daily breakdowns.

Interpreting the API Response

The API response will contain an array of data points, each representing a day. Each data point will have a value (the total fan count at the end of that day) and an end_time (the timestamp for that day). You can then parse this data to find the fan count for your specific desired date.

{
  "data": [
    {
      "name": "page_fans_lifetime",
      "period": "day",
      "values": [
        {
          "value": 10000,
          "end_time": "2023-01-01T08:00:00+0000"
        },
        {
          "value": 10015,
          "end_time": "2023-01-02T08:00:00+0000"
        },
        {
          "value": 10030,
          "end_time": "2023-01-03T08:00:00+0000"
        }
      ],
      "title": "Lifetime Total Likes",
      "description": "Lifetime: The total number of people who have liked your Page.",
      "id": "{page-id}/insights/page_fans_lifetime/day"
    }
  ],
  "paging": {
    "previous": "...",
    "next": "..."
  }
}

Example Graph API response for page_fans_lifetime