{
  "id": "k9LsuhavE9G6MwSk",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Track Facebook page engagement to Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "14c66494-f48e-4a2f-91b1-8288b644ba68",
      "name": "Manually Run Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -800,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c4581d8f-cb49-4497-a904-1ed2259578e3",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -560,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cfg-max-posts",
              "name": "max_posts",
              "type": "number",
              "value": 3
            },
            {
              "id": "cfg-graph-version",
              "name": "graph_api_version",
              "type": "string",
              "value": "v21.0"
            },
            {
              "id": "cfg-wait-seconds",
              "name": "wait_seconds_between_posts",
              "type": "number",
              "value": 2
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e5f17658-fc4e-4b2d-a09a-edcdf8da939d",
      "name": "Daily Schedule (Optional)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -800,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "24a300a2-2280-4f79-9610-a2ca747515a3",
      "name": "Get Facebook Page Info",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        -288,
        480
      ],
      "parameters": {
        "node": "me",
        "options": {},
        "graphApiVersion": "={{ $('Configuration').item.json.graph_api_version }}"
      },
      "typeVersion": 1
    },
    {
      "id": "8bccb0fb-a384-4111-b2c6-77fa9258e734",
      "name": "Get Recent Page Posts",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        0,
        480
      ],
      "parameters": {
        "node": "={{ $json.id }}/feed",
        "options": {
          "fields": {
            "field": [
              {
                "name": "id"
              },
              {
                "name": "message"
              },
              {
                "name": "created_time"
              }
            ]
          },
          "queryParameters": {
            "parameter": [
              {
                "name": "limit",
                "value": "={{ $('Configuration').item.json.max_posts }}"
              }
            ]
          }
        },
        "graphApiVersion": "={{ $('Configuration').item.json.graph_api_version }}"
      },
      "typeVersion": 1
    },
    {
      "id": "e03e93ee-6fbc-4099-bde5-9a021e34ae9a",
      "name": "Split Out Each Post",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        288,
        480
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1
    },
    {
      "id": "3d6a7ae9-0cfe-4a19-b34f-100e9f38306a",
      "name": "Fetch Post Comments",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        560,
        208
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ $json.id }}",
        "options": {
          "fields": {
            "field": [
              {
                "name": "id"
              }
            ]
          },
          "queryParameters": {
            "parameter": [
              {
                "name": "order",
                "value": "reverse_chronological"
              },
              {
                "name": "summary",
                "value": "true"
              },
              {
                "name": "filter",
                "value": "stream"
              }
            ]
          }
        },
        "graphApiVersion": "={{ $('Configuration').item.json.graph_api_version }}"
      },
      "typeVersion": 1
    },
    {
      "id": "db6a3ee6-5802-4e25-8cd2-6be4ec6b634a",
      "name": "Format Comment Count",
      "type": "n8n-nodes-base.set",
      "position": [
        848,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fc-post-id",
              "name": "post_id",
              "type": "string",
              "value": "={{ $('Split Out Each Post').item.json.id }}"
            },
            {
              "id": "fc-comment-count",
              "name": "comment_count",
              "type": "number",
              "value": "={{ $json.summary?.total_count ?? 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b99fb119-ad64-493e-a644-62403d9653e7",
      "name": "Combine Engagement Metrics",
      "type": "n8n-nodes-base.merge",
      "position": [
        1120,
        480
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "7335bc9a-2b35-43b5-8031-620808c7849a",
      "name": "Fetch Post Reactions",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        560,
        480
      ],
      "parameters": {
        "edge": "reactions",
        "node": "={{ $json.id }}",
        "options": {
          "fields": {
            "field": [
              {
                "name": "type"
              }
            ]
          },
          "queryParameters": {
            "parameter": [
              {
                "name": "order",
                "value": "reverse_chronological"
              },
              {
                "name": "summary",
                "value": "true"
              }
            ]
          }
        },
        "graphApiVersion": "={{ $('Configuration').item.json.graph_api_version }}"
      },
      "typeVersion": 1
    },
    {
      "id": "ea279f9f-de5e-4946-98db-843683609723",
      "name": "Format Like Count",
      "type": "n8n-nodes-base.set",
      "position": [
        848,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fl-post-id",
              "name": "post_id",
              "type": "string",
              "value": "={{ $('Split Out Each Post').item.json.id }}"
            },
            {
              "id": "fl-like-count",
              "name": "like_count",
              "type": "number",
              "value": "={{ $json.summary?.total_count ?? 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f76e598f-f0e7-4f04-bbd7-d315f3c93978",
      "name": "Fetch Post Shares",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        560,
        768
      ],
      "parameters": {
        "node": "={{ $json.id }}",
        "options": {
          "fields": {
            "field": [
              {
                "name": "id"
              },
              {
                "name": "message"
              },
              {
                "name": "created_time"
              },
              {
                "name": "shares"
              }
            ]
          },
          "queryParameters": {
            "parameter": [
              {
                "name": "order",
                "value": "reverse_chronological"
              }
            ]
          }
        },
        "graphApiVersion": "={{ $('Configuration').item.json.graph_api_version }}"
      },
      "typeVersion": 1
    },
    {
      "id": "1a46cf61-a359-4f14-b000-be2e94d146b7",
      "name": "Format Share Count",
      "type": "n8n-nodes-base.set",
      "position": [
        848,
        768
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fs-post-id",
              "name": "post_id",
              "type": "string",
              "value": "={{ $('Split Out Each Post').item.json.id }}"
            },
            {
              "id": "fs-post-message",
              "name": "post_message",
              "type": "string",
              "value": "={{ $('Split Out Each Post').item.json.message }}"
            },
            {
              "id": "fs-share-count",
              "name": "share_count",
              "type": "number",
              "value": "={{ $json.shares?.count ?? 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4c9e2026-3fe6-4160-9933-75c592cd735d",
      "name": "Save Engagement to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1424,
        496
      ],
      "parameters": {
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Count Facebook Engagement"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "8391ead7-8eb8-4606-b024-4083a4b405f0",
      "name": "Rate Limit Pause",
      "type": "n8n-nodes-base.wait",
      "position": [
        1696,
        496
      ],
      "parameters": {
        "amount": "={{ $('Configuration').item.json.wait_seconds_between_posts }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "07a27371-ffa3-45ac-ac98-5b7d2db3e222",
      "name": "Sticky Note 4f86f853",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 780,
        "height": 1780,
        "content": "# Track Facebook page engagement to Google Sheets\n# \ud83d\udce5  [Open full documentation on Notion](https://automatisation.notion.site/Course-Track-Facebook-page-engagement-to-Google-Sheets-3a03d6550fd98157b27bf6177ca7a660)\n\n## How it works\nThis workflow tracks engagement (likes, comments, shares) for your Facebook Page's most recent posts and logs one consolidated row per post to Google Sheets.\n\nIt starts from a manual trigger or an optional daily schedule, reads your settings from the Configuration node, fetches your Page feed, and splits it into individual posts. For each post, it fetches comments, reactions and shares in parallel, combines the three metrics into a single row, and upserts it into your Google Sheet using the Post ID as a unique key so re-runs update existing rows instead of duplicating them. A short wait between posts protects you from Facebook API rate limits.\n\n## Setup\n1. Create a Facebook Graph API credential in n8n using a Page access token from the Graph API Explorer.\n2. Connect your Google Sheets account.\n3. Open \"Save Engagement to Sheet\" and pick your spreadsheet + tab (columns: POST ID, POST, LIKES, COMMENTS, SHARES).\n4. Adjust values in \"Configuration\" (max posts to analyze, Graph API version, pause between posts).\n5. Run manually to test, or enable the schedule trigger for daily tracking.\n\n## Requirements\n- A Facebook Page you manage plus a Graph API Explorer access token\n- Google Sheets account connected in n8n\n- A spreadsheet with columns: POST ID, POST, LIKES, COMMENTS, SHARES\n\n## Customization\n- Change `max_posts` to analyze more or fewer recent posts.\n- Adjust `wait_seconds_between_posts` if you hit Facebook rate limits.\n- Swap the manual trigger for the schedule trigger to automate daily tracking.\n- Add more metrics (e.g. reach, impressions) as extra parallel branches feeding the same Merge node.\n\nNeed help customizing?\nContact me for consulting and support : [Linkedin](https://www.linkedin.com/in/doctor-firass/)\n\n# MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new YouTube channel](https://www.youtube.com/@DrFiras_AI). Here I'll share videos and Shorts with practical tutorials and FREE templates for n8n.\n\n[![The AI Doctor](https://www.dr-firas.com/the-ai-doctor.png)](https://www.youtube.com/@DrFiras_AI)"
      },
      "typeVersion": 1
    },
    {
      "id": "85b6489e-ed26-43fd-b81a-59f8d21712f4",
      "name": "Sticky Note 5d9ebeeb",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        752
      ],
      "parameters": {
        "color": 7,
        "width": 476,
        "height": 184,
        "content": "## Trigger & Configuration\nStart manually or on a daily schedule, then set your variables once in Configuration."
      },
      "typeVersion": 1
    },
    {
      "id": "ea9c257a-a96e-41f9-a309-10196180c177",
      "name": "Sticky Note e7c14113",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        752
      ],
      "parameters": {
        "color": 7,
        "width": 508,
        "height": 184,
        "content": "## Collect page & feed data\nFetch page info, get the recent feed, split into individual posts."
      },
      "typeVersion": 1
    },
    {
      "id": "6503a0e2-708f-4c3e-a501-39f7813717ad",
      "name": "Sticky Note 8a215fb9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        976
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 264,
        "content": "## Fetch engagement metrics\nThree parallel branches fetch comments, reactions and shares for each post."
      },
      "typeVersion": 1
    },
    {
      "id": "c0111600-68d1-4db3-b9e4-5ac86338292d",
      "name": "Sticky Note 3ac8fd36",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        752
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 200,
        "content": "## Combine & store results\nMerge the three metrics into one row per post and upsert it into Google Sheets, then pause to respect rate limits."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "fc22ff1a-c0d8-40c2-ab37-5beff32dad25",
  "nodeGroups": [],
  "connections": {
    "Configuration": {
      "main": [
        [
          {
            "node": "Get Facebook Page Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Post Shares": {
      "main": [
        [
          {
            "node": "Format Share Count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Like Count": {
      "main": [
        [
          {
            "node": "Combine Engagement Metrics",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Format Share Count": {
      "main": [
        [
          {
            "node": "Combine Engagement Metrics",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Fetch Post Comments": {
      "main": [
        [
          {
            "node": "Format Comment Count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Each Post": {
      "main": [
        [
          {
            "node": "Fetch Post Comments",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Post Reactions",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Post Shares",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Post Reactions": {
      "main": [
        [
          {
            "node": "Format Like Count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Comment Count": {
      "main": [
        [
          {
            "node": "Combine Engagement Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Recent Page Posts": {
      "main": [
        [
          {
            "node": "Split Out Each Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manually Run Workflow": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Facebook Page Info": {
      "main": [
        [
          {
            "node": "Get Recent Page Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Engagement to Sheet": {
      "main": [
        [
          {
            "node": "Rate Limit Pause",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Schedule (Optional)": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Engagement Metrics": {
      "main": [
        [
          {
            "node": "Save Engagement to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}