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

I’ll explain the step by step method to track Facebook Like, Comment & Share in Real Time in Google Analytics. The events will take place on facebook platform.

You can also use other analytics tools to send this data.

Here you can capture the Events on Facebook Page Feed. So if you share any posts on your page, then you can capture events on the posts (Like, Comment, Share)

Here’s a small demo:

  • Capture Events on FB page post – Like, Comment, Share.

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

  • Capture Emoticons

Facebook-Live-Tracking-Emoticons

 

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. You can open it in new tab to check the post.
  • Event Action: The actions on the post such as
    • Like
    • Comment
    • Share
    • Love
    • Haha
    • Wow
    • Sad
    • Angry

Also, Only unique events per user will get captured. So, if user comments your same post two times (within 30 min session timeout), it will only capture as 1 (unique events).

This is because 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 Actions per User or Unique Events per User.

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.

I have tried to simplify many things and also combined some backend authorization functionalities.

Just follow these 6 steps and you’ll be ready in no time.

Here, I have used

Facebook Real Time API
oAuth Google Scripts

 

UPDATE: THE ACCESS HAS BEEN BLOCKED BY FACEBOOK FOR NEW APPS. 

Due to recent scams, Facebook is taking some actions listed here.

Unfortunately, We’ll have to wait until future updates. Check here for more info: https://developers.facebook.com/status/issues/205942813488872/

Note: The below process won’t work until future updates by facebook. 

 

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

Step 1

 

Track Facebook Page Feed Events - Step - 1

 

Step 2

  • Go To Google App Scripts > Click ‘Start Scripting’
  • Name your project by clicking ‘Untitled Project’. (Facebook Page Feed – GA)
  • Go To Resources > Libraries.
  • Paste this script Id –>’ 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF ‘
    > Click Add > Click Save.
  • Copy the Real Time Facebook Page Feed Tracking in Google Analytics [Updated on 13-10-2017] script & paste it.

Facebook-Step2.2 - Add OAuth Library

Track Facebook Page Feed Events - Step - 2

Now, Enter the

  • App ID as CLIENT_ID
  • App Secret as CLIENT_SECRET
  • GA property ID (UA-xxxxxxxx-x)
  • Facebook Page Name in FB_PAGE_NAME
  • To Log FB Event (as below img), Enter SPREADHSEET_ID from URL

Facebook Spreadsheet Logs

App ID & App Secret - Facebook Apps

 

Step 3

  • Click on Publish > Deploy as web app.. > Change who has access to app to ‘Anyone,even anonymous’ > Click deploy.

Track Facebook Page Feed Events - Step - 3 - Publish web app

  • Complete the authorization process & Copy the web app URL

Facebook Web app - Authorization Process

 

Step 4

  • Go To your App Settings Page > Basic > Add Platform > Website

 

  • Click on Add Platform.
  • Copy the Web App URL you got in step 3.
  • Edit the last ‘exec’ part with ‘usercallback‘ in the URL & paste it.
  • Enter ‘script.google.com’ in App Domains
  • Click Save Changes.

[Updated on 13-10-2017]

  • Go To App Settings Page > Basic
  • Add ‘script.google.com‘ in App domains & ‘https://script.google.com‘ in website URL.

Facebook App Basic_Settings_

 

  • Add these 2 products in the app.

Facebook Add_Products-webhooks&login

 

  • Enter the oAuth Redirect URIs as ‘https://script.google.com/macros/d/{SCRIPT ID}/usercallback’
  • Replace the SCRIPT ID with the script-id found in (script app page) File > Project Properties.

FacebookLoginredurectURL

Step 5

  • Copy the Web App URL from step#3
  • Paste it in new tab > Click On Authorize > Complete the Facebook Authorization Process.
  • If everything goes fine, you’ll receive your page token.

Facebook-Step 6 - Get Page Access Token

Step 6

  • Go To Webhooks.
  • Click New Subscription > Page.
  • Paste the URL in step#3 in CallBack URL & Page Token in step#5 in verify token.
  • Click verify & save.
  • Search for Feed > Click Subscribe

Token_verification

 

Feed_Subscription

 

  • Finally, The Facebook will now send the post request to any updates in facebook feed. Comment on any posts on the page and check your analytics. (comment as user, not as page)

Facebook-Step8 - Facebook Page Post Comment Track in Google Analytics

Important Points:

  • If you make any error in writing the clientID, client secret or page name, just republish the app with NEW versions.
  • Also, you can reset the tokens by running the reset() function in the script.
  • The Facebook logs more events like delete a comment, like, post, etc. I have only selected Like, Comment, Share and other 5 Emotions.
  • 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.


 

Other Articles:

How To Setup & Debug Facebook Pixel Code – Google Tag Manager – Step by Step Guide

10 Powerful Facebook Custom Events To Build Custom Audiences & Define Conversions – Google Tag Manager

Adwords CPA Scanner – Analyze & Reduce High CPAs in Seconds.

Adwords Dynamic Remarketing: Complete Setup Guide

Ritwik is a Web Analyst & Product Marketer. He loves to write technical & easy to understand blogs for Marketers & Entrepreneurs. Focused on Google Analytics, Facebook Analytics, Tag Management, Marketing & Automation Scripts & more. Google Certified Professional. A Firm Believer in Teaching -> Learning -> Growing. :)

Comments (27)

  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 @[email protected]: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)?

Leave a Reply

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