Last active
January 13, 2017 15:42
-
-
Save musantro/b5f2a5a2e4e7266d5d0f1b5e6ccb706e to your computer and use it in GitHub Desktop.
Get Engagement Ratio of your Publications in Facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy & Paste this into your console using F12 in this page: | |
// https://www.facebook.com/yourFacebookPage/insights/?section=navPosts | |
// It console.table you your best posts sorted by Engagement Ratio | |
const pubs = document.querySelectorAll('._5kn3.ellipsis'); | |
const title = document.querySelectorAll("._5591"); | |
const date = document.querySelectorAll('._5k4c > :first-child'); | |
titles = []; | |
title.forEach(item => titles.push(item.innerText)); | |
dates = []; | |
date.forEach(item => dates.push(item.innerText)); | |
let values = []; | |
let ratio = []; | |
pubs.forEach(e => values.push(e.innerText)); | |
for (var i=0; i=values.length/3;i++){ | |
a = values.splice(0,3) | |
ratio.push(a) | |
} | |
ratio = ratio | |
.map(arr => arr.map(item => ((item.slice(-1) == "K") ? (item = item.slice(0,-1).replace(",","."), item = Number(item)*1000) : Number(item)))) | |
.map(i => (i[1]+i[2])/i[0]*100) | |
let engagementRatio = ratio.map(function (e, i) { | |
return [titles[i],dates[i], e]; | |
}); | |
engagementRatio.sort(function(a, b) { | |
return a[2] > b[2] ? -1 : 1; | |
}); | |
console.table(engagementRatio) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment