Track Facebook Like, Comment & Share in Real Time – Google Analytics & Google Sheets

Facebook Live Page Feed Tracking

Last Updated on September 2, 2019 by Ritwik B

I’ll explain one of the ADVANCED methods to track Facebook Like, Comment & Share in Real Time in Google Analytics. These events will take place on the Facebook platform.

The setup will take less than 5 min & you’ll be ready in no time.

Let’s take a look at the awesome features.

  • Track Like, Emoticons, Comment & Share in Google Analytics & Google Sheets.
  • Track Multiple Pages With All Posts.
  • Track Comments in Google Sheets.
  • Create Live Dashboard in Google Sheets.
  • Track Your Top Fans (DIY Top Fan Badge) (Users who like, share, comment more often)
  • Track Most Engaged Posts.
  • & more…

 

Also, you can comment & suggest more use cases as we will have RAW data logs imported to the sheets.  Here’s a small glimpse of what it’ll look like:

#1 Tracking Facebook Page Feed Events In Google Analytics

Track Facebook Like, Comment & Share in Real Time - Google Analytics

#2 Tracking Facebook Page Feed Events In Google Sheet

Facebook Live Page Feed Tracking

Google Analytics Integration:

Here, the only events captured are Like, Comment & Share by the user on the page feed posts. So, if any user performs any of these actions, then data gets captured as follows.

  • Event Category: Facebook post URL.
  • Event Action: The actions by users on the post such as
    • Add
    • Remove
    • Edit
  • Event Label: The action by users on these objects.  
    • Like
    • Comment
    • Share
    • Love
    • Haha
    • Wow
    • Sad
    • Angry

Also, note that…

The User Id in Facebook gets captured as clientID in analytics. (If unaware of clientID in GA, check: Understanding Users in Google Analytics)

So, you can also see the Unique Events (such as like, share, comment) per user.  For Eg: If a user comments your same post two times (within 30 min session timeout), it will only capture as 1 (unique events).

Here’s a glimpse of Actions per User or Unique Events per User report in Google Analytics.

Facebook - Dashboard - Unique Events per User

Here, you can see the posts with most engagements & also the distributions of reactions.

Facebook - Live - Tracking - Dashboards

You can further group the posts by category like News, Promotions, Discount Offers, etc and see the engagements graphs. 

To get more customized reports you can even use sheets as the RAW events data will be logged in it.

Google Sheets Integration:

The columns that will get captured are

  • Date / Time
  • From Name
  • From ID
  • Post ID
  • Post URL
  • Action
  • Item
  • Message
Facebook_Page_Feed_Live_Tracking_In_Google_Sheets

As you can see, by using pivots & filters you can slice & dice the data & also create live dashboards.

I won’t be deep diving into use cases now (maybe that’ll be for a later post). So let’s get started with the setup.

Facebook Update

Important: Even after the quick setup, You’ll need to go through an app review process by Facebook which might take 1-5 days. To go through the process you’ll need to apply for “manage_pages” permission & complete the app review process as per the instructions.

Also, you’ll need a valid business to get approval.

I would suggest to try out the below link to another page post insight tool. (which doesn’t require any verification)

If you want to skip the verification process or don’t need webhooks, you can check this another facebook page post insights tool. Only difference would be you’ll have to manually select a date range to get the page post stats. (Yes… you can even automate it)

Step By Step Method To Track Facebook Page Feed Events in Google Analytics.

Step 1

  • Go To Facebook Apps Page: https://developers.facebook.com/apps/
  • Click Create New App > Enter App Name ‘Real Time GA Tracking’ (you can name anything) > Create App ID.
  • Go To App Settings Page > Basic & fill the following fields
    • App Domains: script.google.com
    • Privacy Policy URL: Enter the URL from your website.
    • Business Use: Support My Own Business
    • Category: Utility & Productivity
  • Scroll below & click on Add Platform > website > “https://script.google.com/”
  • Click Save
Facebook_Basic_App_Setup
  • Click On PRODUCTS + (on left side panel) & Add these 2 products in the app.
    • Facebook Login: (skip the setup process & add webhooks)
    • Webhooks: (we’ll configure this report)
Facebook Add_Products-webhooks&login

Step 2

  • Open & Create New Google Spreadsheet.  Go To Tools > Script Editor.
  • Name your project by clicking ‘Untitled Project’. (Facebook Page Feed – GA)
  • Go To Resources > Libraries.
  • Paste this script Id –>’ 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF
    > Click Add > Click Save. (Choose Latest version)
  • Create another HTML file & name it as ‘digiModal.html’.
  • Now you should have 2 files – Code.gs & digiModal.html (Don’t change these names)
  • Copy & Paste the codes to these files from  Facebook Page Feed Live Tracking
Create_HTML_file_-_Facebook_Reporting_Tool
Facebook Page Feed Tracking Files
Facebook-Step2.2 - Add OAuth Library

Step 3

  • Now, you can refresh the sheet or just run the onOpen function.
  • You can now see “FB Feed” in the menu, click on it > Click on Start.
  • Now, Copy the app id & app secret from facebook apps (Settings > Basic) & enter the following fields
    • App ID as CLIENT_ID
    • App Secret as CLIENT_SECRET
    • GA property ID (UA-xxxxxxxx-x)
    • Sheet Name (For Event Logging): Sheet to log events (It will default to the active sheet)
    • Spreadsheet ID (For Event Logging): Spreadsheet ID to log events. (It will default to the current sheet)
  • Click on Publish > Deploy as web app.. > Change who has access to the app to ‘Anyone, even anonymous’ > Click Deploy.
Track Facebook Page Feed Events - Step - 3 - Publish web app

Step 3

Configure Webhooks:

  • Open the Facebook app dashboard > Webhooks. Select “Page” & Click on “Subscribe To This Object”.
  • Paste The copied URL in Callback URL & Token Verify Token as “meatyhamhock” (well you can paste anything here 🙂 )
  • Search for “feed” & subscribe to it. 
  • Make The App Live & Click Confirm.
WebApp_URL_-_Facebook_Page_Feed_Tracking
Page_Subscription_-_Facebook_Page_Feed_Tracking_App
Subscribe_To_Page_feed_events_-_Facebook_Page_Feed_Tracking_App

Configure Facebook Login:

  • You can refresh the sheet or just run the onOpen function.
  • You can now see “FB Feed” in the menu, click on it > Click on oAuth Redirect URI  > Copy the URL
  • Open the Facebook app dashboard > Facebook Login > Settings. Paste the copied URL in “Valid OAuth Redirect URIs” & click save
Facebook_Apps_-_Valid_Oatuh_Redirect_URIs
ValidOauthRedirectURI_facebook_page_feed_apps

Step 4

  • Now, you can refresh the sheet or just run the onOpen function.
  • You can now see “FB Feed” in the menu, click on it > Click on Start.
  • Now, Copy the app id & app secret from facebook apps (Settings > Basic) & enter the following fields
    • App ID as CLIENT_ID
    • App Secret as CLIENT_SECRET
    • GA property ID (UA-xxxxxxxx-x)
    • Sheet Name (For Event Logging): Sheet to log events (It will default to the active sheet)
    • Spreadsheet ID (For Event Logging): Spreadsheet ID to log events. (It will default to the current sheet)
  • Click Save
AppID_&_App_Secret - Facebook App
Configure_Settings_in_Facebook_Page_Feed_Live_Tracking_App

Step 5

  • And Its Done..!!!  Now simply Authorize The App.  If everything goes well you’ll complete the authorization. (Comment if any errors with screenshot).
  • You can now toggle the facebook pages you want to track.
  • To Test, you can simply go to your facebook page & perform any actions on the feed. (like, share, comment on the post, add new post etc.) & check if they are logged in sheet (You can change the log sheet by changing the event logging sheet in the last step)
Facebook_Page_feed_Tracking
Facebook-Step8 - Facebook Page Post Comment Track in Google Analytics

Now the data will get logged to google sheets as well as google analytics in real time. To disable

  1. Sheet logging: Simply save the settings by leaving Sheet Name & Sheet ID fields blank.
  2. Google Analytics: Save the settings by leaving GA property ID blank.

 Also, you can toggle off to turn off page feed tracking Or log Out (FB feed > Log Out)

Important Points:

  • Facebook has recently started app reviews for new apps. You might have to go app review process if you want to implement this as we require manage_pages permission.
  • You can check for the whole lot of subscriptions offered by Facebook API.

Lastly, Don’t forget to experiment. Check the below video for step by step setup.

Ritwik is a product owner at DigiXport. He also loves to write technical & easy to understand blogs for Marketers & Entrepreneurs. A Firm Believer in Teaching -> Learning -> Growing. :)

Comments (33)

  1. Pingback: education

    1. Thanks a lot..!!! No, its not paid. I always write when I learn something & share it with others. 🙂

  2. Pingback: education online courses

    1. Try using Disqus. It has its own anti-spam filter.

  3. Pingback: online education degrees

    1. I too dislike .net. PHP is better in many ways. Any reason your coder wants to switch? maybe he is good in .net than php

  4. Hey Ritwik,

    Thanks for the great explanation, but I think the instructions may be outdated as FB introduced the newer version of the API, which is v2.9. I get this error while I try to authorize the web app on Facebook, with a 400 status code.

    Could you give it a try with the v2.9 version of the API and may be update this post?

    Btw, domain name has a typo in this line:

    Enter ‘scripts.google.com’ in App Domains

    Should’ve been script.google.com.

    Thanks anyway!

    1. Hey JamRock,

      Thanks for the message,
      I guess API v2.3 is getting closed. I ran through all the steps & they are working fine.

      400 status code error is when tokens are expired. Run reset() function & then authorize again. Also, check the page name if entered correctly. Check if any one of the steps are missed.

      Yes, i’ll surely update it with v2.9 & thanks for the correction. Its updated!!!!

  5. there are some mistakes message below, when i try to authorize with facebook

    Request failed for https://graph.facebook.com/v2.8//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”HFr6e… (use muteHttpExceptions option to examine full response). (line 95, file “Code”)

  6. Hi Ritwik:

    I have done thorough evey step you have write in the blog post.

    I still can’t get the correct authorization from facebook.

    It return below error:

    Request failed for https://graph.facebook.com/v2.8//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”DH1A0… (use muteHttpExceptions option to examine full response). (line 95, file “Code”)

    Any idea what might the reason behind it?

    Thanks

    1. Hi Neo,
      Kindly Recheck steps #4,#5,#6. Facebook Needs Login Plugin For Authentication
      Thanks

  7. Hi Ritwik:

    I have done thorough evey step you have write in the blog post.

    I still can’t get the correct authorization from facebook.

    It return below error:

    Request failed for https://graph.facebook.com/… returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”DH1A0… (use muteHttpExceptions option to examine full response). (line 95, file “Code”)

    Any idea what might the reason behind it?

    Thanks

    •Reply•

    1. Hi Neo,
      Facebook Now need Login plugin for authentication. Kindly Recheck steps #4,#5,#6.
      Thanks

      1. I will try that, Thanks for your reply.

  8. Hi Ritwik:

    After doing everything from your post.

    I got stucked with Step 5. I can’t get Facebook Authorized, and can’t get the code.

    Here is the message i received after i click authorize.


    Sorry, something went wrong.

    We’re working on getting this fixed as soon as we can.”

    Bummer!

    Anybody have the same problem?

  9. Hello Ritwik,

    I’m getting a slightly different error when attempting to authorize the app. It reads…

    “Submit for Login Review. Some of the permissions below have not been approved for use by Facebook. Submit for review now or learn more.”

    Any idea what could be causing this? Do I need to submit the app?

    Thanks.

    1. Hi @disqus_Y6HMw5pSgw:disqus ,
      Actually we have not made the facebook app public, which you can do so in App Review > Make it public.
      We are using the setup for our own purposes, so you can ignore the error & continue the auth process.

      1. Hey @Rit@ritwikb:disqus ,

        Okay, I’ve done as you suggest but now I’m getting a different error…

        “Request failed for https://graph.facebook.com/v2.10//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”DPPLt… (use muteHttpExceptions option to examine full response) (line 104, file “Code”)”

        I see that you addressed this same error over at GitHub and suggested that the person revisit steps 4, 5 & 6. I’ve done the same but I’m still getting the error.

        Any ideas where I could be getting hung up?

        Thank you.

        1. I have the exact same error. I follow the exact video steps, don’t know what is the problem…..

          Error message:

          Request failed for https://graph.facebook.com/v2.10//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”A+jEr… (use muteHttpExceptions option to examine full response). (line 105, file “Code”)

          Any idea what is the problem?

  10. Hi Ritwik:

    Thank you for the video.

    I am having problems with Step 5, I can’t get Facebook Authorization Process successfully. It is the same error like before. I have follow exact same steps you have write in your blog and this video.

    The error message is below:

    Request failed for https://graph.facebook.com/v2.10//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”A+jEr… (use muteHttpExceptions option to examine full response). (line 105, file “Code”)

    Any idea what is the problem?

  11. Request failed for https://graph.facebook.com/v2.10//subscribed_apps returned code 404. Truncated server response: {“error”:{“message”:”(#803) Some of the aliases you requested do not exist: subscribed_apps”,”type”:”OAuthException”,”code”:803,”fbtrace_id”:”FaGyK… (use muteHttpExceptions option to examine full response) (line 105, file “Code”)

    Can you help me?

    1. I already follow to step 4.
      In step 5, get token, i have this error.

      My app current in API v2.12

      1. I have the same problem. Can’t track Facebook likes & comments

  12. Request failed for https://graph.facebook.com/v2.10/176648859610543/subscribed_apps returned code 403. Truncated server response: {“error”:{“message”:”(#200) Access to this data is temporarily disabled for non-active apps or apps that have not recently accessed this data due t… (use muteHttpExceptions option to examine full response). (line 105, file “Code”)

    Above is the error code, can you help me?

    Thanks

  13. Amazing tips Rit for Facebook users to telecast live. Recently my friends stop working Facebook app and cannot live I searched over internet and tried many websites to find out a solution for my friend’s Phone. Finally I found your page to solve the problem and tried your tips to handle the problem. know the phone o friend working fine with your tips to solve Facebook problems. Thanks for sharing such a good post about Facebook live problem solution. Now My friend can live easily and can share photos of my carved wooden furniture site and Facebook page https://www.facebook.com/birchii directly to customers easily. Thanks for starting such a great blog for me and the World.

  14. Hello. where can I find the GA property ID (UA-xxxxxxxx-x)?

  15. Hello, thank you for this article. I have a question and also a problem I ran into.

    1. What if I want to track comments for a personal profile and not page? What would I put in as the Page ID?

    2. I tried going to the Web App URL and it says, “sorry we are unable to open the file at this time”

    Please help

  16. First of all thank you for this wonderful page easy to understand and very informative too.
    Through your page i want to share something which i found through a google search that is related to Recurring Payments API Integration it is very effective because Integrating recurring payments is a great way to improve cash flow and simplify billing for businesses With the recurring payment model, businesses don’t have to chase late payments or send out reminders to customers with each billing cycle.
    There are so many benefits we have to get through that platform so i am glad to share it with you please check it out.
    bank cloud March 14, 2023 at 8:36 am Reply

  17. data-api
    here I share something useful topic and I have given the link so that visitors get the benefits and get knowledge about that platform please once check it out

  18. Hi
    thanks for the informative post.Unlock your brand's potential with Calgary social media optimization . Enhance engagement, boost visibility, and drive growth through tailored strategies that connect you with your target audience effectively.

Leave a Reply

Your email address will not be published. Required fields are marked *