How to import social media statistics into Google Sheets: The Import Cookbook

Google Sheets has a powerful and versatile set of IMPORT formulas that can import social media statistics.

This article looks at importing social media statistics from popular social media channels into a Google sheet, for social network analysis or social media management. If you manage a lot of different channels then you could use these techniques to set up a master view (dashboard) to display all your metrics in one place.

The formulas below are generally set up to return the number of followers (or page likes) for a given channel, but you could adapt them to return other metrics (such as follows) with a little extra work.

Caveats: these formulas occasionally stop working when the underlying website changes, but I will try to keep this post updated with working versions for the major social media statistics.

Example workbooks: Each example has a link to an associated Google Sheet workbook, so feel free to make your own copy: File > Make a copy....

Contents

  1. Facebook
  2. Twitter
  3. Instagram
  4. Google+
  5. Youtube
  6. Pinterest
  7. Alexa rank
  8. Quora
  9. Reddit
  10. Spotify
  11. Soundcloud
  12. GTmetrix
  13. Bitly
  14. Linkedin
  15. Sites that don’t work and why not
  16. Closing thoughts
  17. Resources

How to import social media statistics into Google Sheets with formulas


facebook icon Import Facebook data

November 2018 update: The Facebook formula is working again! The trick is to use the mobile URL πŸ˜‰ Thanks to reader Mark Oakley for this discovery.

Start with the mobile Facebook page URL in cell A1, e.g.

https://mobile.facebook.com/benlcollinsData

Here is the formula to extract page likes:

=REGEXREPLACE(REGEXREPLACE(JOIN("",REGEXEXTRACT(LOWER(SUBSTITUTE(INDEX(IMPORTXML(A1,"//@content"),2),",","")),"(\d+)([km]*)")),"m","000000"),"k","000")*1

The following screenshot shows these formulas:

Facebook Data

See the Facebook Import Sheet.

^ Back to Contents


twitter logo Import Twitter data

Start with the Twitter handle URL in cell A1, e.g.

https://twitter.com/benlcollins

Here is the formula to extract follower count:

=QUERY(IMPORTXML(A1,"//span[@class='ProfileNav-value']/@data-count"),"limit 1 offset 2")

Pro-tip: If you find this formula gives an error, wrap it in an IFERROR function and call the IMPORTXML function a second time, but add a “/” to the end of the Twitter handle. This should then pull out the follower number for you (it requires that your Twitter handle in cell A1 does NOT have a “/” at the end):

=IFERROR(QQUERY(IMPORTXML(A1,"//span[@class='ProfileNav-value']/@data-count"),"limit 1 offset 2"),QUERY(IMPORTXML(A1&"/","//span[@class='ProfileNav-value']/@data-count"),"limit 1 offset 2")

The following screenshot shows these formulas (this is an older screenshot and all references to “Col2” should be changed to “Col3”):

twitter social media statistics

Note 1: These Twitter formulas seem to be particularly volatile, working fine one minute, then not at all the next. I have two Sheets open where it’ll work in one, but not the other!

See the Twitter Import Sheet.

^ Back to Contents


Build Business Dashboards With Google Sheets and Data Studio

Digital marketing dashboard in Google Sheets
  • Learn how to build beautiful, interactive dashboards in my online course.
  • 9+ hours of video content, lifetime access and copies of all the finished dashboard templates.
  • Learn more

instagram logo Import Instagram data

Start with the Instagram page URL in cell A1:

https://www.instagram.com/benlcollins/

Then, this formula in cell B1 to extract the follower metadata:

=IMPORTXML(A1,"//meta[@name='description']/@content")

To extract details from this is now relatively simple. Here’s the number of followers:

=VALUE(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)"))

Note, for large numbers of followers, the number will be in the format 250.2k for hundreds of thousands or 32.7m for millions, in which case we need to use some IFs and SUBSTITUTEs to deal with this, so our formula becomes:

=IF(ISNUMBER(SEARCH("k",REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)"))),SUBSTITUTE(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)"),"k","")*1000,IF(ISNUMBER(SEARCH("m",REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)"))),SUBSTITUTE(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)"),"m","")*1000000,REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(.{1,})(?: Followers)")*1))

Here’s the number following:

=VALUE(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(?:Followers, )(.{1,})(?: Following)"))

Similar to the number of followers above, you may need to wrap with IFs and SUBSTITUTE formulas if the number is of the thousand or million format.

Here’s the number of posts:

=VALUE(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"(?:Following, )(.{1,})(?: Posts)"))

The following screenshot shows these formulas:

instagram data

If this causes an error, try these alternative methods:

=VALUE(IFERROR(REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(A1,"//*"),"select Col3"),"followed_by.{15,}"),"[0-9]+"),REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(A1,"//*"),"select Col3"),".{1,}.has_blocked_viewer"),"[0-9]+")))
=VALUE(REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(A1,"//*"),"select Col3"),"followed_by.{15,}"),"[0-9]+"))

Oo-er, this one’s a bit funky!

I wasn’t able to import the precise “followed_by” class so I’ve used some REGEX to extract the followers count tag from the data I’ve imported.

In a nutshell, the REGEXEXTRACT formula extracts this snippet: followed_by": {"count": 120}, "country_bl. The second REGEXEXTRACT formula then extracts the the digits and finally VALUE converts to a number.

One further datapoint we can grab from the instagram page is the link, with this formula:

=SUBSTITUTE(REGEXREPLACE(INDEX(SORT(QUERY(IMPORTDATA(A1),"select Col9"),1,TRUE),1,1),"external_url: ",""),"""","")

See the Instagram Import Sheet.

^ Back to Contents


google-plus logo Import Google+ data

With the URL in cell A1:

https://plus.google.com/+benlcollins

this formula in cell B1, again using REGEX to extract the specific datapoint, will get the followers of the Google+ account:

=VALUE(SUBSTITUTE(REGEXEXTRACT(QUERY(IMPORTXML(A1,"//div[@class]"),"select Col2"),"[0-9].*[0-9].*[0-9]{1,}.followers")," followers",""))

The following screenshot shows this formula (actually shows a prior version of this formula):

Pro-tip: If you find this formula gives an error, wrap it in an IFERROR function and call the IMPORTXML function a second time, but add a “/” to the end of the Google+ handle. This should then pull out the follower number for you (it requires that your Google+ handle in cell A1 does NOT have a “/” at the end):

=IFERROR(VALUE(SUBSTITUTE(REGEXEXTRACT(QUERY(IMPORTXML(A1,"//div[@class]"),"select Col2"),"[0-9].*[0-9].*[0-9]{1,}.followers")," followers","")),
VALUE(SUBSTITUTE(REGEXEXTRACT(QUERY(IMPORTXML(A1&"/","//div[@class]"),"select Col2"),"[0-9].*[0-9].*[0-9]{1,}.followers")," followers","")))

See the Google+ Import Sheet.

Alternative formula to try for Google+, submitted by one of the students of my online Google Sheets and Data Studio dashboard course:

=VALUE(SUBSTITUTE(IMPORTXML(A1,"//div[@class='C98T8d GseqId b12n5']")," followers -",""))

^ Back to Contents


youtube logo Import YouTube data

Start with the YouTube channel URL in cell A1:

https://www.youtube.com/benlcollins

To get the number of subscribers to a YouTube channel, use this formula in cell B1:

=MID(QUERY(IMPORTXML(A1,"//div[@class='primary-header-actions']"),"select Col1"),31,20)

To get a channel’s total views, you need to use the about page as your URL in cell A1:

https://www.youtube.com/user/benlcollins/about

Then use this formula to extract channel views:

=VALUE(INDEX(IMPORTXML(A1,"//span[@class='about-stat']"),2,2))

The following screenshot shows these formulas:

youtube data

See the YouTube Import Sheet.

^ Back to Contents


pinterest logo Import Pinterest data

In cell A1, enter the following URL, again replacing benlcollins with the profile you’re interested in:

https://www.pinterest.com/bencollins/

Then in the adjacent cell, B1, enter the following formula:

=IMPORTXML(A1,"//meta[@property='pinterestapp:followers']/@content")

to get the following output (screenshot shows older version of the formula, latest one is above and in the template file):

pinterest data

Note, you can also get hold of the profile metadata with the import formulas, as follows:

=IMPORTXML(A1,"//meta[@name='description']/@content")

See the Pinterest Import Sheet.

^ Back to Contents


alexa logo Import Alexa ranking data

Here there are two metrics I’m interested in – a site’s Global rank and a site’s US rank.

Global Rank

To get the Global rank for your site, enter your URL into cell A1 (replace benlcollins.com):

http://www.alexa.com/siteinfo/benlcollins.com/

and use the following helper formula in cell B1:

=QUERY(ArrayFormula(QUERY(IMPORTDATA(A1),"select Col1") & QUERY(IMPORTDATA(A1),"select Col2")),"select * limit 1 offset " & MATCH(FALSE,ArrayFormula(ISNA(REGEXEXTRACT(QUERY(IMPORTDATA(A1),"select Col1") & QUERY(IMPORTDATA(A1),"select Col2"),"Global rank icon.{10,}"))),0)+1)

and then extract the rank in cell C1:

=VALUE(REGEXEXTRACT(B1,"[\d]{3,}"))

US Rank

Assuming you have the Alexa URL in cell A1 again, then the US rank is extracted with this helper formula:

=QUERY(ArrayFormula(QUERY(IMPORTDATA(A1),"select Col1") & QUERY(IMPORTDATA(A1),"select Col2")),"select * limit 1 offset " & MATCH(FALSE,ArrayFormula(ISNA(REGEXEXTRACT(QUERY(IMPORTDATA(A1),"select Col1") & QUERY(IMPORTDATA(A1),"select Col2"),"title='United States Flag'.alt.{50,}"))),0))

and this formula to extract the actual rank value:

=VALUE(REGEXEXTRACT(B1,"[\d]{3,}"))

The following screenshot shows these formulas:

alexa data

See the Alexa Ranking Import Sheet.

^ Back to Contents


Build Business Dashboards With Google Sheets and Data Studio

Digital marketing dashboard in Google Sheets
  • Learn how to build beautiful, interactive dashboards in my online course.
  • 9+ hours of video content, lifetime access and copies of all the finished dashboard templates.
  • Learn more

quora logo Import Quora data

In this instance, I’ve imported the number followers Barack Obama has on Quora.

Quora is a little bit different because I need to use the URL and the profile name in my formula, so I’ve kept them in separate cells for that purpose. So in cell A1, add the generic Quora URL:

https://www.quora.com/profile/

And then in cell B1, add the profile name:

Barack-Obama-44

Then the formula in C1 to get the number of followers is:

=VALUE(QUERY(IMPORTXML(A1&B1,"//a[@href='/profile/"&B1&"/followers']"),"select Col2"))

The following screenshot shows this formula:

quora data

See the Quora Import Sheet.

^ Back to Contents


reddit logo Import Reddit data

Here, I’m using the funny subreddit as my example.

In A1:

https://www.reddit.com/r/funny/

To get the number of followers of this subreddit, use this formula in cell B1:

=IMPORTXML(A1,"//span[@class='subscribers']/span[@class='number']")

Bonus: To get the number of active viewers of this subreddit:

=IMPORTXML(A1,"//p[@class='users-online']/span[@class='number']")

The following screenshot shows these formulas:

reddit data

See the Reddit Import Sheet.

^ Back to Contents


spotify logo Import Spotify monthly listeners

Here’s a method for extracting the number of followers an artist has on the music streaming site Spotify.

First, find your favorite artist on Spotify: https://open.spotify.com/browse/featured

Copy the URL into cell A1 (it’ll look like this):

https://open.spotify.com/artist/2ye2Wgw4gimLv2eAKyk1NB

(This is Metallica, yeah 🀘)

Then put the following formula into cell A2 to extract the monthly listeners:

=N(INDEX(IMPORTXML(A1,"//h3"),2))

See the Spotify Import Sheet.

^ Back to Contents


soundcloud logo Import Soundcloud data

Start with the Soundcloud page URL in cell A1, e.g.

https://soundcloud.com/fleecemusic

Here is the formula to extract page likes:

=ArrayFormula(VALUE(REGEXEXTRACT(QUERY(SORT(IFERROR(REGEXEXTRACT( IMPORTXML(A1,"//script"),"followers_count..\d{1,}"),""),1,FALSE),"select * limit 1"),"\d{1,}")))

Alternative formula:

Here is an alternative formula to extract the page metadata, which includes the likes:

=IMPORTXML(A1,"//meta[@name='description']/@content")

the formula to extract likes is:

=VALUE(REGEXEXTRACT(REGEXEXTRACT(SUBSTITUTE( IMPORTXML(A1,"//meta[@name='description']/@content"),",",""),"\d{1,}.Followers"),"\d{1,}"))

and to extract the “talking about” number:

=VALUE(REGEXEXTRACT(REGEXEXTRACT(SUBSTITUTE( IMPORTXML(A1,"//meta[@name='description']/@content"),",",""),"\d{1,}.Tracks"),"\d{1,}"))

The following screenshot shows these formulas:

soundcloud data

See the Soundcloud Import Sheet.

^ Back to Contents


gtmetrix_logo Import GTmetrix data

GTmetrix is a website that analyzes website performance.

You need to grab the correct URL before you can start scraping the data. So navigate to the GTmetrix site and enter the URL and hit analyze. You’ll end up with a URL like this:

https://gtmetrix.com/reports/www.benlcollins.com/BcHv78bP

Those last 8 characters (“BcHv78bP”) appear to be unique each time you run an analysis, so you’ll have to do this step manually.

Then in column B, I use this formula to extract the Page Speed Score and YSlow Score, into cells B1 and B2:

=ArrayFormula(ABS(IMPORTXML(A1,"//span[@class='report-score-percent']")))

and this formula in cell B3, to get the page details (Fully Loaded Time, Total Page Size and Requests) in cells B3, B4 and B5:

=IMPORTXML(A1,"//span[@class='report-page-detail-value']")

The following screenshot shows these formulas:

gtmetrix data

See the GTmetrix Import Sheet.

^ Back to Contents


Bitly logoImport Bitly click data

Bitly is a service for shortening urls. They provide metrics for how many clicks you’ve had on each bitly link, e,g.

Bitly link metric data for import to Google Sheets

Taking a standard Bitly link (e.g. http://bitly.com/2mmW1lr) and appending a “+” to it will take you to the dashboard page, with the metrics. Then we can use the import data function, a query function and a REGEX function to extract the click metrics.

User clicks are:

=VALUE(REGEXEXTRACT(QUERY(IMPORTDATA(A9&"+"),"select Col1 limit 1"),"(?:user_clicks...)([0-9]+)"))

and global clicks are:

=VALUE(REGEXEXTRACT(QUERY(IMPORTDATA(A9&"+"),"select Col5"),"(?:global_clicks:.)([0-9]+)"))

Clicks from the Bitly network are then simply the user clicks subtracted from the global clicks.

The following screenshot shows these formulas:

Bitly data import in Google Sheets

See the Bitly Import Sheet.

^ Back to Contents


linkedin logo Import Linkedin data

This formula is no longer working for extracting Linkedin followers and I have not found an alternative.

In cell A1:

https://www.linkedin.com/in/benlcollins/

This formula used to work to get the number of Linkedin followers, but no longer:

=QUERY(IMPORTXML(A1,"//div[@class='member-connections']"),"select Col1")

and the output:

linkedin import

There is no example sheet for Linkedin since the formula is no longer working.

^ Back to Contents


cancel icon Sites that don’t work and why not

I’ve tried the following sites but the IMPORT formulas are unable to extract the social media statistics:

  • Linkedin (see above)
  • Similar Web
  • Twitch
  • Mobcrush
  • Crunchbase
  • Angel.co
  • Majestic SEO

These are all modern sites built using front-end, client-side Javascript frameworks, so the IMPORT formulas can’t extract any data because the page is built dynamically in browser as it’s loaded up. The IMPORT formulas work fine on sites built in the traditional fashion, with lots of well formed HTML tags, where the social media statistics are embedded into the site markup that is passed from the server.

Compare this screenshot of the source code for Mobcrush, built using Angular JS it looks like (click to enlarge):

Angular front end

versus what the source code looks for this page on my website (click to enlarge):

benlcollins code

You can see the code for my site has lots of tags which the IMPORT formulas can parse, whereas the other site’s code does not.

If anyone knows of any clever way to get around this, do share!

Otherwise, you’re next option is to venture down the API route. Yes, this involves coding, but it’s not as hard as you think.

I’ll be posting some API focussed articles soon. In the meantime, check out my post on how to get started with APIs, or for a peak at what’s coming, take a look at my Apps Script + API repo on GitHub.

Loading error

Also, even when these formulas are working, they can be temperamental. If you work with them a lot, sooner or later you’ll find yourself hitting this loading issue all the time, where the formulas stop displaying any results:

Loading error

^ Back to Contents


settings logo Closing thoughts

These formulas are unstable and will sometimes display an error message.

I’ve found that adding or removing the final “/” from the URL can sometimes get the formula working again (the issue is to do with caching).

I can make no guarantee that these will work for you or into the future. Whilst researching this article, I came across several older articles where many of the formulas no longer work. So things change!

To summarize: Caveat Emptor!

^ Back to Contents


link icon Resources

^ Back to Contents


As always, leave any comments, corrections or request other social media statistics below.

Icons from Freepik.

294 thoughts on “How to import social media statistics into Google Sheets: The Import Cookbook”

  1. This is awesome! Thanks for putting it together.

    One metric I’m interested in adding is YouTube Subscribers, any chance you would know how to do this already?

    1. Thanks Michael, glad it was helpful!

      Try this formula to get YouTube subscribers:

      =mid(query(IMPORTXML(A1,"//div[@class='primary-header-actions']"),"select Col1"),31,20)

      where your YouTube account url is in cell A1.

        1. Nice work! Interesting to see that it takes a minute or so to load all of the data, with that many formulas.

          Also, I like your G+ formula, it’s much neater and more succinct than mine, so I’ll update the article. Cheers!

    1. Me too, can’t see anything that has changed in the source code though. Sometimes it grabs the followers counts, sometimes not. It’s a temperamental system as advertised πŸ™‚

    2. Hey Dave,

      I’m getting an #N/a error with my Linkedin import formulas too. The actual error message is telling me “Could not fetch url”, so the import function isn’t able to access the Linkedin url, so Linkedin must have changed something on their side I think. Am looking for a solution too! I’ll update the article if I can find an alternative solution.

      Cheers,
      Ben

  2. Hi Ben

    I found a code that works, not sure why

    =importXML(“http://services.runescape.com/m=forum/users.ws?searchname=Pad&lookup=view”,”//p[@class=’user-post-count’]/strong”)

  3. Trying to post some code here, but it seems to disappear in the replay. Let’s try again…

    Copied the actual number (XPath) from Inspect view on followers page:
    //*[@id=”control_gen_3″]/div[1]/p
    or
    //*[@id=”control_gen_3″]/div[1]/p/a/span[1]

    Source from followers page:


    1,068 followers

  4. Hi and thanks for sharing this Ben!

    I set up my Google Spreadsheet as described in your article. It worked like a charm when I tested it for about 10-20 profiles at a time.

    But once I expanded the formulas to several hundreds/thousands of profiles the fields just remained blank. Even the fields that were displaying follower counts just fine before went empty after refreshing.

    Is there a limitation on queries? Does anybody elseexperience this problem?

    Thanks! Mike

    1. Hi Mike,

      I understand there used to be a limit of 50 in the old Google Sheets (see here: http://gappstips.com/google-sheets/google-spreadsheet-limitations/), but it was removed in the new Google Sheets, although there still seems to be some confusion (see: https://productforums.google.com/forum/#!topic/docs/AYGh1hZXKgI).

      Do the formulas give you any error messages? You could try running them in several separate Sheets and then aggregating into one master sheet using IMPORTRANGE() formulas.

      Ben

      1. Thanks for the reply Ben! I will have a look into using several separate sheets and then aggregating into one master sheet using IMPORTRANGE() formulas.

        Regarding error messages:
        – Facebook works like a charm, even with a thousand accounts (unsing the script)
        – Twitter returns a zero even though the account clearly has more followers
        – Instagram and YouTube remain blank, no error message though

        Hope that helps with further analysis! πŸ™‚

        Best, Mike

  5. Thanks again. It works perfectly. Would you happen to know why the Twitter one gives perpetual error (sometimes it shows and others it disappears).

    Would you have an alternate string.

    Best

    1. Hi ssen,

      Sometimes adding or removing the final β€œ/” from the URL will make the formula work again. Caching can occasionally prevent the formulas functioning properly, so adding/removing the “/” effectively creates a new url, which forces the formula to fetch the data again. Also, these formulas are somewhat volatile overall, so will break if the structure of the webpage changes or the function cannot parse the webpage.

      I’ll post any alternatives here if I find them, so keep an eye out.

      A more robust way to get hold of social media data would be to use Google Apps Script to build a basic app that is connected to each service’s api, but this is obviously a great deal more work. It’s something I’ll write a post on in the future.

      Cheers, Ben

  6. Hi! Ben,
    I’m super happy with this post that you made. Two days ago I noticed that Instagram code (probably with their update) its making GSheets crash so bad.
    Will you help me to figure it out?

    Cheers,
    Gracias.

    1. Hi Ben,

      Big fan of the codes as it has helped me tremendously. I’m experiencing a similar issue that Luisa is experiencing. The formula does not seem to work for Instagram, and displays the follower count as “#N/A”. Also, I’ve noticed a large amount of code text located to the left-hand side of the page whenever I click on the follower count. Would you be able to assist?

      Thanks,
      Michael

    2. Hi Luisa!

      Yes, I had the same problem when I revisited my sheet. The code on Instagram’s website has probably changed. Thanks for letting me know! I’ll work on it and see if I can find an alternative πŸ˜‰

      Ben

      1. And Michael, ditto for your comment. Thanks for stopping by and letting me know. I had the same weird chunk of text on the left side of my Google Sheet. I’ve removed the Instagram formula for now, pending an update!

        Ben

  7. Hi Ben

    Thank youΒ β€”Β and all your commenters β€”Β for doing the hard work on this and sharing. This is an absolutely fantastic resource!

    As with other commenters, i’ve noticed the Regex for the Instagram formula returns quite a strange error.

    Finally, i’m wondering how often this data is automatically updated from the source? In searching around Google for how to get social media data into Sheets, I found this website which has similar formulas, and offers a script to re-fetch the data: https://support.geckoboard.com/hc/en-us/articles/207238327-Using-Google-Sheets-IMPORTXML-function-to-display-data-in-Geckoboard#automaticupdate

    Would that be necessary? Or is simply reloading the Sheet each time its reopened enough to fetch any updated data?

    Thanks once again, this really is a fantastic post!

    1. Hey Jamie,

      Thanks for stopping by and leaving a comment. Yes, the instagram and linkedin ones have stopped working right now. It’s a temperamental function!

      I think that whenever you open or refresh your worksheet the import formulas will go fetch the latest data, although I understand that caching can sometimes mean the most recent data is not fetched. If you have your Google Sheet open and the data changes on the underlying website (e.g. you gain a follower), then this will NOT automatically update in your sheet. You’d need to write a small script, per that (excellent) Geckoboard article.

      Thanks,
      Ben

  8. Hi Ben,

    Fellow developer here :). Thank you so much for your contribution, it really helps.

    Question tho, when I use your formula for Instagram, the spreadsheet gave me an error of “#VALUE!” – “Error
    Unable to parse query string for Function QUERY parameter 2: NO_COLUMNCol3”. Also, when I look at your demo, the value of Instagram on B8 is written “#N/A”. Is that normal?

    Thanks,
    Sophie

    1. Hey Sophie, thanks for stopping by and leaving a comment. Unfortunately the instagram formula as described had stopped working. I’m working on a fix tho! πŸ™‚

      Ben

      1. Hi Ben,
        I’m experiencing the same problem as Sophie; in some rows it gives results, but in most of them it returns to

        β€œ#VALUE!” – β€œError
        Unable to parse query string for Function QUERY parameter 2: NO_COLUMNCol3”

        I am using it for number of likes and comments of the posts in Instagram.

        Any help?

        1. Hi! Are you using the latest formula: =REGEXEXTRACT(query(IMPORTXML(A1,"//*"),"select Col3"),"followed_by.{12,}")? It’s been updated from the one which was causing issues for Sophie.

          It’s working well for me. Note that these IMPORTXML formulas are somewhat limited, so won’t work well if you’re trying to extract data for thousands of profiles at once.

          Other things you could try:
          – Replace “Col3” with “C”, this sometimes works instead.
          – Try adding a trailing backslash “/” (or removing it if you have one) to the instagram url. This forces the formula to re-run and overcomes the issue of these formulas sometimes not working because the data has been cached.

          Hope that helps!

            1. Sure thing, so “Col3” refers to the third column of the data that is imported by the IMPORTXML formula. This is the column that contains the follower information. The “{12,}” is regular expression in the REGEXEXTRACT formula, which extracts the snippet of data relating to the follower count.

              You can use this formula in the adjacent cell to then extract the count from the string:

              =mid(B1,find("{",B1)+9,find("}",B1)-find("{",B1)-9)

              So like this:

              Instagram extract

              Thanks!

  9. Hi Ben,

    Thanks a lot for the article! Unhappily, it does not seem to be working for retrieving data from Twitter. I get the following error: Impossible to analyse the parameter 2 of Query, QUERY : NO_COLUMN: Col2.

    1. Hi Vladimir,

      Yes, I’ve had this happen before too. Sometimes deleting and re-copying the formula fixes the situation. Otherwise, try changing “Col1” to “A”, “Col2” to “B” etc. and see if that helps (so your query would be “select B” rather than “select Col2”).

      Thanks,
      Ben

  10. Hi Ben,

    could it be that the instagram formula is not working anymore? It would be cool to update this one.

    Cheers,
    Daniel

    1. Hi Daniel,

      Hmm, seems to still be working for me. πŸ€”

      Are you using the updated formula I posted?

      In cell A1: https://www.instagram.com/benlcollins/

      In cell B1:
      =REGEXEXTRACT(query(IMPORTXML(A1,”//*”),”select Col3″),”followed_by.{30}”)

      In cell C1:
      =mid(B1,find(“{“,B1)+9,find(“}”,B1)-find(“{“,B1)-9)

      On my sheet, this one appears to still be working fine. The previous formula I posted had stopped working.

      Otherwise, sometimes re-pasting the formula resolves the issue, or adding/removing the final “/” on the url, e.g. try “https://www.instagram.com/benlcollins” without the “/” at the end.

      Let me know if it works for you.

      Ben

          1. Hey Ben,

            First of all thanks of these! Quite useful stuff!

            I’ve been having a problem with the IG formula

            =VALUE(IFERROR(REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(A1,”//*”),”select Col3″),”followed_by.{15,}”),”[0-9]+”),REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(A1,”//*”),”select Col3″),”.{1,}.has_blocked_viewer”),”[0-9]+”)))

            Its giving me back the number of people the account follows instead of the followers it has. Do you know why?? What do I need to change in the formula?! Thanks in advance

            1. Hmm, not sure. But try this formula:

              =REGEXEXTRACT(REGEXEXTRACT(query(IMPORTXML(A9,"//*"),"select Col3"),"followed_by.{12,}"),"[0-9]+")

              which is just a shortened version of that long formula. I’ve checked mine now and it’s giving me the followers count.

              Cheers,
              Ben

  11. I have a problem…

    the Facebook script

    it works good but,
    everyday it get error to me from (08:00 PM) to (01:20 AM)
    then run good from (01:20 AM) to all day until stoped again !!!
    sometime get error from (04:00 PM) or (06:00 PM)…. et.
    and get work again in (01:20 AM) !!!

    if you have solution to this problem, or can help me with any information.. !

    and thank you alot dear

    1. Hi Mohamed,

      Hmm, very strange. I’ve occasionally had a script stop working for a short period of time, but usually start working again within a few hours. I’ve not had a time issue like this one though.

      If it’s still happening, I’d suggest posting a question on the Google forums to see if anyone there can help you out: https://productforums.google.com/forum/#!topicsearchin/docs/category$3Aspreadsheets or try posting to Stack Overflow: http://stackoverflow.com/questions/tagged/google-apps-script

      Thanks,
      Ben

  12. Hi Ben,

    the twitter formula is working at the beginning, but then suddenly you get a #value error that i can’t get rid of anymore. Do you know how to solve this?

    Thank you so much!
    Daniel

    1. Hey Daniel,

      Yes, sometimes these import formulas stop working πŸ˜•

      I think one of the issues is with caching, so try re-pasting the formula or adding/removing the final β€œ/” on the url, e.g. if you’re trying β€œhttps://twitter.com/benlcollins/” with the β€œ/” at the end, then remove the last “/” and try “https://twitter.com/benlcollins”, or vice versa.

      Of the two twitter formulas in the worksheet, the second one seems to be more reliable!

      Thanks,
      Ben

        1. Nice work Daniel!

          For anyone else reading this, you’ll need to make a copy of the sheet (File > Make a copy…) to see the formula working. In the view-only mode it was showing a #N/A, but then worked perfectly when I made my own copy.

          Going to go away and spend sometime decoding this now πŸ˜‰

          1. This Twitter fix for follower count works! Thanks!!
            here is the formula from Daniel’s sheet:
            =iferror(substitute(substitute(query(importHTML(D2,”table”,3),”select Col3″),char(10)&”Followers”,””),”,”,””),substitute(substitute(query(importHTML(E2,”table”,3),”select Col3″),char(10)&”Followers”,””),”,”,””))

            Replace D2 with the cell containing the https://twitter.com/{username}

  13. Phenomenal work! There is a lot to play with here. I am particularly impressed that you cracked Instagram – I had messed with that in years past with no dice.

    On Twitter, a better route I found to deal with the 10K or 10M abbreviations, is to pull from the mobile URL. It gives precise numbers. You can see this in action in my (ever-evolving) TweetMasterDash: http://bit.do/tweetmasterdash

    Heart @yorudan

    1. Thanks @yorudan! Great work with your TweetMasterDash spreadsheet, impressive stuff. Clever idea to pull from the mobile URL to get around that 10K or 10M abbreviations. Thanks for sharing!

      Cheers, Ben

  14. Hi Ben,

    this morning I realized that the fb_likes function is not working anymore. Are you experiencing the same problem? It says “TypeError: Cannot call method “getText” of null. (line 8).”

    Regards,
    Daniel

      1. Hi Ziya,

        See my comment to Daniel above. That version of the api is no longer supported! Will post a fix if/when I find one!

        Cheers,
        Ben

    1. Hi Daniel,

      Thanks for letting me know. Facebook recently deprecated v2.0 of their API, which caused this fb_likes function to stop working. Digging a little further into the fb_likes api call, I found the following error message confirming it:


      REST API is deprecated for versions v2.1 and higher (12)

      Also confirmed on the following FB page: https://developers.facebook.com/docs/apps/changelog

      Facebook API v2.0 deprecated

      Boo!

      Working on a solution, though I fear it will be more complex and involve authenticated calls to the API. Great project for the future though!

      Cheers,
      Ben

        1. Hey Jake,

          Both of these formulas appear to be working at the moment to import Facebook page likes:

          =value(REGEXEXTRACT(REGEXEXTRACT(substitute(IMPORTXML(A1,"//meta[@name='description']/@content"),",",""),"\d{1,}.likes"),"\d{1,}"))

          or

          =substitute(importxml(A1,"//span[@id='PagesLikesCountDOMID']")," likes","")

          Thanks. I need to update the post!

          Ben

          1. do you have any formula that would allow to get the number of member and the title of a facebook group .. i spent a whole night from your page formula but i reached by limit πŸ™

            for the members its in that code :
            1 710 membres

            for the title and example :
            HERE IS GROUP NAME

  15. Hi Ben,

    thanks for the good work – really helped me a lot setting up a google Dashboard for social media monitoring!

    For the facebook problem I could find a workaround extracting the likedata out of the meta-data of the fb page. It’s clunky (I think it gets tangled up in the fb security check), but it works in the long run. Using the following formula:

    =IMPORTXML(https://www.facebook.com/buzzfeed, “//meta[@name=’description’]/@content”)

    returns the string:

    “BuzzFeed. 8.189.336 likes Β· 1.507.877 talking about this. Worth sharing.”

    REGEXEXTRACT gets the value of likes/followers out of the string, here for values up to hundreds of millions:

    =Value(Regexextract(G59,”([0-9]\d{0,3}.[0-9]\d{0,3}.[0-9]\d{0,3}|[0-9]\d{0,3}.[0-9]\d{0,3}|[0-9]\d{0,3}).likes”))

    (which for sure can be optimized).

    Best,
    Jo

    1. Hi Jo,

      This is AWESOME! Thank you for sharing your solution with the rest of us, worked perfectly for me. Here’s an alternative to your regex formula:

      =REGEXEXTRACT(REGEXEXTRACT(substitute(B2,",",""),"\d{1,}.likes"),"\d{1,}")

      and the whole thing can be combined into a single formula:

      =value(REGEXEXTRACT(REGEXEXTRACT(substitute(IMPORTXML(A8,"//meta[@name='description']/@content"),",",""),"\d{1,}.likes"),"\d{1,}"))

      I’m sure it can still be optimized!

      Cool to see you use the VALUE function as well. I’d forgotten about that, so have been using this trick to convert to numbers =A1*1.

      Here’s a sheet with all of these setup.

      Cheers,
      Ben

    1. Thanks for the heads-up. Minor tweak to the REGEX formula and it’s working again. The new formula is:

      =REGEXEXTRACT(query(IMPORTXML(A1,"//*"),"select Col3"),"followed_by.{12,}")

      and then, to extract the exact follower count:

      =mid(B1,find("{",B1)+9,find("}",B1)-find("{",B1)-9)

      Cheers,
      Ben

    1. Hey Steven, I’ve updated the instagram formula now and it works on any size account for me. Hopefully that fixes it for you too.

      Cheers,
      Ben

    1. Yes, you can. Great solution. I guess I had QUERY on the brain when I was writing all these different formulas, so missed the better solution to use INDEX. Will update the post to reflect. Thanks!

  16. Ben,
    Your formula to grab the subscribers count on YouTube works great! Is there anything similar that will show a channel’s total views?

      1. Brilliant! I’ve never paid much attention to the “about” page and didn’t realize that info was there. It works like a charm. Thanks for your help!
        Jim

  17. Hello, trying tiny coping facebook method and always getting a “TypeError: Unable to call the method “getText” of the object null. (line 6).” message. Please, link me for updating info, best and thank in advance.

    1. Hi! The custom Facebook formula no longer works because they’ve changed the API. However, the other formulas listed in the article using the IMPORTXML method are still working.

  18. Ben, One last question (where I think I know the answer). Is there a way to grab a range of channel views on YouTube, specifically “Last week,” without getting into API’s? I suspect that that info on the Analytics page isn’t XML. I’ve set my Analytics default to “Last week,” but haven’t had any luck grabbing it. I’ve tried isolating what I think is the target from the html source code, but either that doesn’t work or I’ve isolated the wrong target.

    1. Yes unfortunately I think this is the realm of APIs. I’ve tried a few variations of IMPORTXML but can’t get past a message like this: “One account. All of Google.Sign in to continue to YouTube…..”. I’m sure it’ll be possible with Apps Script and APIs.

  19. Hi! This is a big help. However, I can’t seem to get Pinterest’s to work any longer- even the update you posted in the end of August.

    Any help would be appreciated! Thanks!

    1. Hey Daria,

      The updated formula:

      =substitute(query(IMPORTXML(A1,"//a"),"select * limit 1 offset 5"),"Followers","")*1

      is still working for me. The Google Sheet was out of date though, which I’ve updated just now.

      Try adding or removing a final “/” to the address – sometimes these IMPORT formulas get “stuck” with cached data, so you need to make Google think it’s a new URL and get the formula to re-import.

      Hope that helps.

      Cheers, Ben

  20. I am also having a problem getting the Pinterest followers. Using the code you provided I get this error.

    Function MULTIPLY parameter 1 expects number values. But ‘8.5kPins’ is a text and cannot be coerced to a number.

    I can of course take out the *1 at the end and it shows the text value. But I am wanting to of course perform analysis on the numbers

    1. Hey James,

      So what’s happening here is that the number of Pinterest follower is large enough that they abbreviate the number to show ‘8.5k’ with the ‘k’ representing 1000. So this will require some modification to the formula. Try this, where your Pinterest address is in cell A1:

      =value(substitute(substitute(query(IMPORTXML(A1,"//a"),"select * limit 1 offset 3"),"kPins","00"),".",""))

      Note – this pulls out the number of pins, it’ll be different if you want the number of followers:

      =value(substitute(substitute(query(IMPORTXML(A1,"//a"),"select * limit 1 offset 5"),"kFollowers","00"),".",""))

      Also, another note, these two formulas work for the thousands short-hand (“k”). If the Pinterest account has millions of followers, and the account shows e.g. “4.5MFollowers”, then you’ll need to change the “kFollowers” to “MFollowers” and the “00” to “00000” in the above code to make it all work.

      Hope that helps!

      Ben

  21. Hello Ben

    Thank you very much for sharing these techniques.
    Might there be a way to extract the likes for one certain Facebook post, not the likes for the account?

    Thank you in advance,

    Roselle

    1. Hi Roselle,

      Haven’t tried this but I think this will require using script to access the API, which is a lot more complext than the IMPORT formulas. If I get time I’ll look into it tho and update you.

      Cheers,
      Ben

    1. I have some issues with the instagram import. It seems that the search for “followed_by” is not unique for every account, because sometimes the formula finds “followed_by_viewer” and that’s the wrong place to search for the “count” element. Does anyone have a solution for that?

      Cheers,
      Daniel

      1. Hey Daniel,

        So that example has 0 followers right? So the HTML is different and the original formula can’t parse this example. A slight modification to the formula picks out the zero count:

        =REGEXEXTRACT(query(IMPORTXML(A1,"//*"),"select Col3"),"follows.{12,}")

        The original formula is working fine otherwise for me. If you have any other accounts you know where the formula isn’t working then let me know. The fix above may work in those cases too.

        Cheers,
        Ben

        1. Dave – can you share the Instagram example that’s not working? Formula still working fine for me, so I need to see what the error is.

          In the meantime try this slight modification, which might do the trick:

          =REGEXEXTRACT(query(IMPORTXML(A1,"//*"),"select Col3"),"follows.{12,}")

          Let me know if that works…

          Thanks, Ben

          1. Hey Ben,

            No joy, I got this error message on column c, row 1 – “In FIND evaluation, cannot find ‘}’ within ‘follows”: {“count”: ‘.”

  22. Ben,

    Looks like Alexa formula needs a tweak. There are now two strong tags with class = “metrics-data align-vmiddle”. And the first one also has an html comment in it (not sure if that is what breaks it).

    IMPORTXML returns “Imported Xml content can not be parsed”.

    I’m trying to get just the US rank, but I still struggle with understanding xpath queries.

    Cheers,
    Dave

      1. I’d love to see a solution to this as well. It looks like they’re pointing to their API for a solution now; was that there before?

        Thanks for opening my eyes to all sorts of new possibilities with Sheets, Ben! Between this and your page scraping article, I’ve got a lot of fun new things to try!

    1. Hey Dave,

      Tried and tried, but haven’t been able to find a solution using the IMPORTXML method. So instead I found an alternative using IMPORTDATA and lots of matching array formulas – it’s a monster, so hopefully in time a better solution will surface, but for now it works.

      Here’s the US rank formulas, with URL in A1, then in B1:

      =trim(query(sort(ArrayFormula(regexextract(query(importdata(A1),”select Col1″)&query(importdata(A1),”select Col2″),”United States Flag.+span.{10,}”)),1,TRUE),”select * limit 1″))

      Then in C1, extract the number:

      =value(regexextract(B1,”[\d]{3,}”))

      The Global rank formula is even worse! Here’s a link to a sheet with the solution:

      https://docs.google.com/spreadsheets/d/17Zcwuxxpm72elqE8QgA54qSAjz6OnSKsB2RMpP_GA_s/edit?usp=sharing

      Cheers,
      Ben

    1. Hi Jamie,

      Unfortunately, I don’t think it’s possible because you need to be logged in to see the number of clicks on any shortlinks you’ve created. So the IMPORT formula can’t get past the login to see the data.

      Ben

  23. Hey Ben,

    The Instagram update was working fine for awhile but now it’s not returning the followers count, just the following.

    “ProfilePage””: [{“”user””: {“”username””: “”uidesignpatterns””, “”country_block””:
    null, “”connected_fb_page””: null, “”follows””: {“”count””: 5820},
    “”requested_by_viewer””: false, “”followed_by””: {“”count”””

    1. Hey Dave,

      So you’ll need to change the formulas that parse this “ProfilePage” block. Try putting these two formulas in the adjacent cells:

      In A1: https://www.instagram.com/benlcollins/

      In B1: =mid(query(IMPORTXML(A1,"//*"),"select Col3"),find("ProfilePage",query(IMPORTXML(A1,"//*"),"select Col3")),190)

      In C1: =trim(regexreplace(regexreplace(B1,"[[:punct:]]",""),"[[:alpha:]]",""))

      In D1: =value(TRIM(RIGHT(SUBSTITUTE(C1," ",REPT(" ",LEN(C1))),LEN(C1))))

      Here’s a link to a working example in a spreadsheet: https://docs.google.com/spreadsheets/d/1lBJVPgD_bUPilxkoqiHcYNUms3uSLLcnAP6QPaPL3JU/edit?usp=sharing

      Hope that helps!

      Ben

  24. Hi, Ben,

    Is it possible to grab likes count from a specific Instagram publication?

    For example I tried to parse viewer_has_liked from your photo: https://www.instagram.com/p/BNTMO8eg_Z_/ β€” with formula: =REGEXEXTRACT(query(IMPORTXML(A1;”//*”);”select Col3″);”viewer_has_liked.{25}”)

    But the result was only: viewer_has_liked”: false, “nodes”: [{“use
    There is no: count”: 26.

    Thanks for your articles, Ben!

  25. Hi Ben,

    Thank you so much for this formula! I’m working on a French version of google and translated it and it mostly works a treat!

    I have a few questions for you:

    1. Are you aware of a way to remove the commas from the numbers displayed? In French they are considered as points and my totals are messed up slightly.

    2. Some of my instagram profile accounts don’t work with the formula for example https://www.instagram.com/rodrigo_noriega/ only brings me back 600 or so whereas the profile has 55.6K followers any ideas as to why?

    3. Anyway to copy the values of this say each month or week into a different cell so as to see the progress of one’s social reach as well as not having to enter numbers? I try copying only the value of the cell and it doesn’t want to work :/

    Again thank you! This really has saved me a lot of time πŸ™‚

    Elena

    1. I just answered my q1 with an extra cell using replace/substiute formula it’s this in the French version of sheets: =SUBSTITUE(A1;”,”;””;)
      and this in the English version; =SUBSTITUTE(B6,”,”,””,)

    2. Hey Elena,

      Catching up on the blog comments now! Great that you’ve solved question 1, nice work πŸ™‚

      For Q2: Hmm, I’m getting errors with the Instagram formulas now, so looks like I’ll need to rework them. I’ll try to get round to some kind of update article in early 2017…

      For Q3: Have a look at this post about saving social media data using a little snippet of Apps Script. I think that should do the trick for you.

      Hope that helps!

      Ben

  26. Hi Ben,

    Why are you using the xyz function even if we get the number of followers by using pqr function?

    xyz = query(IMPORTXML(A1,”//a[@data-nav=’followers’]”),”select Col2″)

    pqr = IMPORTXML(A1,”//a[@data-nav=’followers’]”)

    1. Hi Sowmay,

      The QUERY() wrapper function is used to pull out the follower number only, because the output of the IMPORT formula spreads across two columns, something like:

      Followers | 1,919

      So the QUERY just returns 1,919 and removes the word “followers”.

      Cheers,
      Ben

      1. But this is not showing the correct/updated value in my case
        The value saw when inspecing the browser page was correct , but the query returned an old/cached value .
        Even suffixing the random number didn’t help

  27. Hi Ben,

    This is amazing work πŸ™‚

    Is there a way to pull the latest tweet date? I’d like to pull that to show when the last time an account tweeted.

    Many thanks

  28. Hi Ben,

    Is there a way you could include streaming sites? Twitch and Mobcrush? We really want to collect an accurate follower count.

      1. Hey Sarah,

        So I tried both of these sites but unfortunately I couldn’t extract data with the IMPORT formulas. πŸ™

        They’re built with client side Javascript, so don’t really have the metrics data in a structured XML or HTML format for the formulas to extract. You’ll have to see if they have APIs you can use.

        Cheers,
        Ben

  29. Great article! Helped me a lot.

    I have a comment and a doubt:

    – I tried using the IG formula and it worked just in some cases. Doing some sniffing around, I tried this generic formula instead and it worked properly. I hope it helps: =REGEXEXTRACT(mid(query(IMPORTXML(B2,”//*”),”select Col3″),find(“followed_by”&CHAR(34),query(IMPORTXML(B2,”//*”),”select Col3″)),35), “[0-9]+”)

    – Now the doubt: The values that I get using these formulas are updated automatically or is there a way to update them manually?

    Thanks!

    1. Hey Henrique, I believe they get updated every time you open the sheet (or click into the formula and hit enter). However, I know they sometimes get hung up with cached data, so fail to update. What you can do is add a “/” to the end of the URL to force it to update.

      Cheers,
      Ben

  30. Hello Ben,

    Thank you so much for the update everything is working great! Would you have a suggestion on how to extract the estimated unique views of a website via, say, similar web?

    Thank you for all your help!

    Elena

    1. Hey Elena,

      I tried Similar Web but it’s not possible to retrieve data via these IMPORT formulas because of the underlying structure of the website (more details why here). You’d have to look into the API to see if it’s possible.

      Cheers,
      Ben

  31. Hi Ben,

    Is there any tricks to get the live cricket score from websites like cricbuzz.com etc. to in the spreadsheet. And is it possible to automatically get refreshed.

    Hope i get the answer.

    Thanks,

  32. Hello Ben, so much formula for fb pages and Instagram, but why nothing for the Fb groups ? Even when you are not yet a member of a Fb group you can see the information im trying to retrieve: name of the group, number of member , and Group description .
    Any genius willing to help me ?

  33. Hi,

    i tried implementing the code for facebook to get page views and total reach for my page but I am getting #REF error. What to do?

  34. Ben! This is tremendously helpful, thank you for sharing your expertise.

    On Instagram, is there a way to pull the “likes” and “comments” reported from recent Instagram posts from an Instagram main page the way you pulled Instagram followers?

    Thanks,
    -Brian

  35. Hey Ben,

    My twitter one was working fine but now it just returns the word ‘Followers’ instead of the number. Can you think of a solution to this?

  36. The script for twitter is not working for me. Anybody can help me out? At the meantime, does anybody has a script for retrieving weibo followers count? Thanks in advance

    1. Hey Matthew, see my response to Sam Moore’s question: the fix is pretty easy: change β€˜select Col2’ in the formula to β€˜select Col3’ and you’re back on track.

      1. If it helps. I am currently experimenting with:

        =VALUE(IFERROR(REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(B19,”//*[@id=’react-root’]/section/main/article/header/span/span”),”select Col3″),”followed_by.{15,}”),”[0-9]+”),REGEXEXTRACT(REGEXEXTRACT(QUERY( IMPORTXML(B19,”//*[@id=’react-root’]/section/main/article/header/span/span”),”select Col3″),”.{1,}.has_blocked_viewer”),”[0-9]+”)))

        Which returns: “Imported content is empty.”
        I believe this is unfortunately down to the way that the Hashtag pages are built, being mostly Javascript and dynimac loading.

        Though since I am not an expert on the subject, I could also be wrong.

    1. Hi Morten,

      I’ve found two ways to do it – one is reliable but loses a bit of accuracy, whilst the other extracts the correct number but is a fragile formula and needs changing for different hashtags.

      Method 1:

      =value(substitute(substitute(regexextract(substitute(IMPORTXML(A1,"//meta[@name='description']/@content"),".",""),"\d{1,}.\d{1,}."),"m","00000"),"k","000"))

      and the output should be: 77,700,000

      This formula should work for different hashtags, e.g. I tried it with #data and got 327,900

      Method 2:

      This formula will give the exact result, but relies on a specific column reference which changes for different hashtags, so there is not guarantee this always work:

      =value(regexextract(query(sort(query(importdata(A1),"select Col242"),1,true),"select * limit 1"),"\d{1,}"))

      which gives the result: 77,763,164

      For the data hashtag, I have to change the reference to Col242 to Col224, as follows (in bold):

      =value(regexextract(query(sort(query(importdata(A1),"select Col224"),1,true),"select * limit 1"),"\d{1,}"))

      So it’s not really ideal. There may be a way to search for the column, but haven’t had time to work on that yet.

      Hope that helps!

      Cheers,
      Ben

      1. Hi Ben,

        That’s perfect. The first one is accurate enough for me. One thing I did run into is with #Denmark and #Fotos. For some reason for both of them I get the error:


        Function REGEXEXTRACT parameter 2 value “\d{1,}.\d{1,}.” does not match text of Function REGEXEXTRACT parameter 1 value “27m Posts – See Instagram photos and videos from β€˜fotos’ hashtag”.

        Which to be honest, I am a bit clueless about what means.

        1. Ah ha! The culprit here is that the extract has ’27m’ with no decimal place (before it was 77.7m) so we should change the formula very slightly to this:

          =value(substitute(substitute(regexextract(substitute(IMPORTXML(A1,"//meta[@name='description']/@content"),".",""),"\d{1,}.\d{0,}."),"m","00000"),"k","000"))

          I’ve changed the second \d{1,} to \d{0,} (bolded above) which fixes this issue.

          Cheers,
          Ben

          1. Actually ended up a little more complicated than I first thought when I dug around. Turns out that the “k” and “m” to represent thousands and millions can have various permutations with decimal places etc. So I ended up working on the formula a bit more and came up with this beast, which I think now gets all the variations correctly:

            =value(substitute(if(iserror(search(".",REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"[\d]{1,}[\D]{0,1}[\d]{0,3}.{0,1}\s"))),substitute(substitute(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"[\d]{1,}[\D]{0,1}[\d]{0,3}.{0,1}\s"),"k","000"),"m","000000"),substitute(substitute(REGEXEXTRACT(IMPORTXML(A1,"//meta[@name='description']/@content"),"[\d]{1,}[\D]{0,1}[\d]{0,3}.{0,1}\s"),"k","00"),"m","00000")),".",""))

            Phew!

  37. Hi Ben,

    Thank you for all the info this is truly gold! I was wondering is there any way to use these formulas for posts as well? for example to get the number of likes and comments? Thanks in advance!

  38. Thanks for redirecting me here. This really is gold as Andy said above. How did you find out the column #? I would like to get some exact results, as I’m tracking frequency of use. No rush on this answer! I appreciate all you’ve done!

    1. Good question! It’s a bit of trial and error to be honest. I haven’t found a way to automate it yet… I’ll post here if I do.

      So try just this plain formula in cell A3 say: =importdata(A1)

      From Instagram, copy the exact number of followers (e.g. 53274) and search for that in your sheet (using Ctrl + F, or Cmd + F on Mac) making sure to remove the thousand separators “,”. Then count how many columns that is (quick tip to do this, use the formula =column() in a blank cell in this column to find the number).

      Then plug this number back into your original formula and you should be set.

      Hope that helps!

      Ben

  39. Hey Ben, it seems the Pinterest formula is not working anymore. We have only a handful of followers but the formula returns a 0 (so not the *k issue here) . Your sheet also shows a 0.

    I tried changing the column numbers and hacking the formula a bit as I did with Twitter, but without the desired result this time. Any ideas on how to fix it?

    1. Thanks for the heads up Ruben!

      I’ve changed the formula to this, which seems to work better:

      =IMPORTXML(A1,"//meta[@property='pinterestapp:followers']/@content")

      I’ll update the article shortly.

      Cheers,
      Ben

  40. Hi Ben

    I have tried to import number of visits from Similarweb with using of Importxml function, Without success.

    Can you help me ?
    Thanks

  41. Hi, I’e been using the formula listed here to pull Spotify followers into a google sheet and recently it stopped working for all of them. Is anyone having this issue? Here is a sample

    A1 »» Weyes Blood
    B1 »» 3Uqu1mEdkUJxPe7s31n1M9
    C1 »» https://api.spotify.com/v1/artists?ids=
    D1 »» =C3&B3
    E1 »» =VALUE(MID(QUERY(IMPORTDATA(D1),”select Col1 limit 1 offset 7″),9,25))

    When I click the link in D1 this is what shows up:
    {
    “error” : {
    “status” : 401,
    “message” : “No token provided”
    }
    }

    This article has been incredibly helpful and pulling social stats has slashed time my team spends harvesting data each week. Any help here will be much appreciated, and many many thanks to Ben for sharing this amazing article!

      1. Good Morning,

        I was just curious if you were able to look in to the Spotify “access token” issue. Thanks! Great article!

      2. Thank you for this article Ben! It’s amazing.

        I was also curious if you’ve had a chance to look into getting the Spotify import working again.

  42. Hi Ben,
    This is an awesome post, super helpful! The Twitter code is not working for me though: it’s returning an error that says “Imported Xml content can not be parsed.”
    Any ideas on how to fix this?

    1. Update: it displayed the error for like an hour, then all of a sudden the data showed up… So I tried the formula on a few more pages, and those are still showing the error…
      Perhaps it just takes more time than the rest to load..?

  43. Hi Ben,
    thanks so much for the help that you gives to all this people.

    Just a little question here:

    I need a way to extract the hashtags from Instagram in a easy and faster way. So i’m not Good with Google Sheets and i thought that maybe you could help me a little bit.
    I was thinking 2 possible way to proceed.

    1 – A formula to extract the word (for example) “#home” from this url ( https://www.instagram.com/explore/tags/home/ ) and see it in a single cell.

    2 – Write the word (for example) “#home” in a cell and automatically the word ‘#home’ go to the url without the ‘#’, so i can write the hashtags in column and see in another column the number of the hashtags.

    I hope that you understand what i’m saying, and i apologize in advance for my bad english.
    Thanks πŸ™‚

    1. Hi Marco,

      Here goes:

      1) For specific examples like the one you shared, this formula will extract the final word assuming that the Instagram URL is in cell A1: =left(RIGHT(A1,len(A1)-39),len(RIGHT(A1,len(A1)-39))-1)

      This won’t work if the start of the URL is different however. In that case you could try this formula: =ArrayFormula(lookup(2,1/(transpose(split(A1,"/"))<>""),transpose(split(A1,"/"))))

      2) For the other way around, supposing you type the word “home” into cell A1, this formula will give you the URL in another cell: ="https://www.instagram.com/explore/tags/"&A1&"/"

      Hope that helps!

      Ben

  44. Just wanted to say thank you for so generously sharing your expertise. You saved me a lot of time and heartache… now I just have to find a way to have the data automatically add itself to a sheet on a daily basis.

    Again, much appreciated.

  45. Hi Ben,

    This is really a helpful post as it helped me extract the count for ‘likes’ on facebook and ‘followers’ on instagram using Google Sheets.

    However, I was wondering if you could help me extract the ‘follower’ count on facebook and ‘post’ count on instagram, for example, on public profiles such as adidas originals?

    I have a whole list of such sites that I need to extract data from on a monthly basis, and was wondering if you could help me with this task. It will most certainly save me a lot of time and increase accuracy of data extracted.

    Would appreciate your feedback.

  46. Hi Ben,

    Again, one more question – more of an issue that I ran in to.

    I tried extracting likes (count) on facebook for adidas (https://www.facebook.com/adidas/) using formula;
    =VALUE(SUBSTITUTE(IMPORTXML(A1,”//span[@id=’PagesLikesCountDOMID’]”),” likes”,””))
    and all the other formulas listed above. However, despite removing the ‘/’ at the end, I still get “#N/A” as my output.

    Any idea what is it that I could be doing wrong?

    Thanks again.

  47. I am having the exact same issue as Diana. Also, I’ve tried to copy your google sheet but it still doesn’t deliver the follower counts. πŸ™

    Thank you for your help!

    Flora

  48. In the last few days I’m getting an “#N/A” error for the Facebook Likes most of the times. Before it worked quite stable … I wonder if Facebook changed anything?

    What is the best/ most stable formular for grabbing Facebook Page Likes at the moment?

    Thanks in advance!

    1. Hey Sepp,

      As you’ve noticed these formulas are somewhat volatile! πŸ˜‰

      Your best bet, to get reliable Facebook data, is to write an Apps Script program to connect, or use a third party service like Supermetrics to connect (see my post on this).

      Cheers,
      Ben

  49. hi ben, is there a formula to track likes, shares and comments for a particular facebook post instead of the page itself?

  50. Hi Ben,

    This has been extremely helpful. Just a quick question…

    I have used the function to get the amount of followers for a bunch of Instagram accounts. Unfortunately, for a few accounts, the formula has given me the amount the account is “following” which is not what I need. I want the amount of “followers”. I have retried both Instagram formulas and am still encountering this issue. Any suggestions on what to do?

  51. Hi Ben,

    very nice overview, thank you for your work! I’m trying to adapt the FB formula to display page likes >1000 but only get the last three digits. They are displayed on the page as, e.g. “3,700 likes” and the formula only grabs the 700, not the 3k πŸ™‚

    Do you have an idea what I need to change?

    Thanks!
    -F.

    1. Oh, never mind – it seems to be working now. Not sure what did it, but suddenly the other formula

      =value(substitute(importxml(A13,"//span[@id='PagesLikesCountDOMID']")," likes","")

      produced the desired results.

  52. Hey, thanks for the formulas. I wonder, can you also adapt the formula to extract Ad data, such as costs, clicks, etc.? Thanks.

    1. Probably not, unfortunately, as this sort of information is usually behind a password, rather than on a public page. So you can either write an apps script program to query the API to get the info or use a program like Supermetrics to do that for you.

  53. For Alexa ranking, instead of using a “helper cell” the two formulas can be combined (simply using output of first formula as input for second.

    For US rank: With your domain name in B1, i.e. mysite.com
    Use the following formula in the cell where you want the rank for the domain name in B1
    =VALUE(REGEXEXTRACT(QUERY(ArrayFormula(QUERY(IMPORTDATA("https://www.alexa.com/siteinfo/"&B1),"select Col1") & QUERY(IMPORTDATA("https://www.alexa.com/siteinfo/"&B1),"select Col2")),"select * limit 1 offset " & MATCH(FALSE,ArrayFormula(ISNA(REGEXEXTRACT(QUERY(IMPORTDATA("https://www.alexa.com/siteinfo/"&B1),"select Col1") & QUERY(IMPORTDATA("https://www.alexa.com/siteinfo/"&B1),"select Col2"),"title='United States Flag'.alt.{50,}"))),0)),"[\d]{3,}"))

    There is also another source to get this data from which allows a much simpler IMPORTXML formula.
    With your domain name in B1, use the following to get US rank.

    =IMPORTXML("https://data.alexa.com/data?cli=10&url="&B1,"//COUNTRY/@RANK")

    Or use the following for Global rank

    =IMPORTXML("https://data.alexa.com/data?cli=10&url="&B1,"//POPULARITY/@TEXT")

    1. Hey Dave,

      Thanks for commenting. I decided against combining the formulas because it became so obnoxious and long! Thank you for persevering!

      But woah, I much prefer the new formulas you’ve submitted! Much neater and simpler. I wasn’t aware of these endpoints. Thanks for sharing πŸ˜‰

      Cheers,
      Ben

  54. Hi Ben,

    Your post helped me extract β€˜likes’ on Facebook and β€˜followers’ on Instagram. Regarding likes on Facebook though, the google sheet that I have absolutely refuses to fetch me data sometimes, this is despite removing the β€˜/’ at the end and recreating the spreadsheet. Any idea what could be done to avoid this problem?

    I was also wondering if you could help me extract β€˜follower’ count on Facebook and β€˜post’ count on Instagram, for example, on public profiles such as adidas originals? For the moment, to extract ‘post’ count on Instagram I use the formula ‘=IMPORTXML(A1,”//meta[@name=’description’]/@content”)’, run a text to column macro, and then a mid + len formula to extract posts. Not a terrible approach I believe, but something more direct would be always better.

    Over and above all this, if there’s a way to get those Facebook followers, it’ll be just fantastic.

    1. Hey Diana,

      Not sure why the facebook formulas aren’t working for you. They’re still ok on my site. Do you have a lot of these IMPORT formulas? Sometimes you can have too many. Sometimes they just give up on you Β―\_(ツ)_/Β―

      The instagram formula has been updated, and I’ve now included a formula to extract Followers, Following and Posts.

      Unfortunately I do not have a formula for the Facebook followers at the moment.

      Cheers,
      Ben

      1. Hi Ben,

        Thank you for these formulas πŸ™‚ Instagram data extraction works perfectly now!
        I have about 50 of these import formulas running in one go. So maybe as you said, that’s a little too much for sheets to process in case of Facebook. But now they seem to work again – I guess that’ll do πŸ™‚
        As for Facebook follower count; please do keep us posted if you manage to construct a functional formula. Currently, this a monthly nightmare πŸ™
        Thank you once more!! Your posts are a life saver! πŸ™‚

        Kind Regards,
        Diana

  55. Hi Ben!

    Thank you so much for putting this together! It was so helpful! I’m trying to do each of these for 1000 different pages. I.e. 1000 fb pages and 1000 twitter handles etc. It is very slow to load progress, and seeing that I have so many to go through and have to update them once a week, I was wondering if there was a way to expedite the loading process. Thanks so much!

    1. Hey Betsy!

      That’s a lot of complex formulas to run!! Your poor computer 😀

      Unfortunately it’s going to be super slow because they’re complex and they have to retrieve third-party data over the web. Not sure there’s much you can do, other than ensure you minimize the number of active formulas by turning any data into values (copy > paste special > values) when you’ve finished with it.

      Cheers,
      Ben

  56. Hi Ben

    Thanks for this – fantastic!

    Do you know if there is a formula that pulls your Instagram posts by date & time and a formula that shows that particular post’s engagement (eg. likes + comments)? Might be too complicated for Google sheets?

    Cheers

        1. Yeah I would love to know how you’re using IFTT to calculate engagement for a profile. Essentially we could use Ben’s formulas for pulling followers and then using IFTT to pull the posts total comments + likes and divide it by followers x 100. Going to attempt to figure this out!

  57. Hey Ben, thanks for all the helpful material πŸ™‚
    Just a quick question,
    When i use the formula to scrape Instagram followers with big fanbases i get an error for example: “Value parameter 161.k cannot be parsed to number”. Any help is much appreciated πŸ™‚

    Thanks!

    1. Hey Spyros,

      Thanks for bringing this to my attention! For large accounts in the hundreds of thousands or millions of followers they abbreviate numbers like this. I’ve updated the Instagram formula (click here) to account for this now, although note that we lose some precision because it’s not the exact number.

      Cheers,
      Ben

  58. Hi Ben,

    Is there a code I could use to extract tweet data from twitter. I am working on a university assignment on finding a correlation between social media and an athletes performance.

    1. Hey! You can get a lot of analytics data from this page but only for your own account (change to your twitter handle): https://analytics.twitter.com/user/benlcollins/tweets

      To get other data, you’ll need to access the twitter api (custom code) or easier, use a third-party service like Supermetrics to do that step for you.

      Cheers,
      Ben

      1. Hi Ben,

        Thank you for your reply.

        “To get other data, you’ll need to access the twitter api (custom code) or easier, use a third-party service like Supermetrics to do that step for you.” – I have been trying to extract tweets using R using the custom code, not been successful yet.
        Supermetrics is a good tool, I’ll play around with it to see if I am able to extract the data that I require for my assignment.

        Regards,
        Shalin

  59. Ben, this is amazing! Is there any way to import Telegram and Slack members? For Slack, without creating an account because I’ don’t trust public Slack channels at this point.

    1. Unfortunately, it’s probably not possible with these formulas. Do you have an example url for each service? It needs to be a publicly facing web page, and you can only scrape data that is not behind a membership wall.

        1. If you have that url in cell A1, then this formula will extract the number of members:

          =value(substitute(regexextract(importxml(A1,"//div[@class='tgme_page_extra']"),"[0-9 ]+")," ",""))

          Hope that helps!

          Ben

  60. I’ve integrated your formulas into a Google Sheet that is receiving data from TypeForm via Zapier so when someone submits their Instagram URL it would be great for data to autogenerate. I can’t seem to figure out how to populate each of these formulas as a new entry comes into this Google Sheet.

  61. Hi Ben!

    Thanks so much for this super helpful article.

    I’m getting this error message for a few of my fb pages, but the formula is working for others.

    Function REGEXEXTRACT parameter 2 value “\d{1,}.likes” does not match text of Function REGEXEXTRACT parameter 1 value “FACEBOOK PAGE NAME HERE. 1.3K likes.”

    Any idea what this means and/or how to fix it?

    Thank you in advance!

    1. Hmm, that is strange. They are quite temperamental, so it’s not uncommon to have them work one day but not the next. You can try adding (or removing) a final slash “/” to your urls and this resets the formulas which sometimes helps.

  62. Hey Ben,
    thx for this article, it’s awesome.

    I have a big problem, I tried to copy all the formula and your entire file too, but an error appears: “Imported Xml content can not be parsed.”

    Can you help me? It’s very strange!

  63. Bro, words can’t describe how much I love your Instagram G spread sheet! Thank you so much for that awesome piece of work – you just saved me hours, if not days of manual research!!!

    Pure value, much love.
    Tim.

  64. Amazing overview Ben, thanks a lot!

    An idea for facebook followers (tested & works):
    =iferror((index(split((index(Importxml(EJ2, "//div[contains(div, 'follow this')]"),13)), " "), 1, 1)), "")

    For medium:
    =iferror((substitute((SUBSTITUTE((index((importxml(EF5, "//div[@class='buttonSet u-noWrap u-marginVertical10']/a[2]")), 1)), "K", "00")),".", "")), "")

    For twitter your formula didnt work for me, so I used this one:
    =IFERROR({(substitute((substitute((index(IMPORTXML(EL2,"//span[@class='ProfileNav-value']"), 3)), "K", "00")),".", ""))}, "")

    and I am working on telegram now. If you have any suggestions how to simplify one of these formulas, let me know πŸ™‚

  65. here is telegram, that was an easy one:

    =iferror((substitute((substitute((index((IMportxml(EE2, "//div[@class='tgme_page_extra']")), 1)), " ", "")), "members", "")),"")

  66. Hi Ben,

    Do you happen to know if there’s a way of important likes/shares on individual posts that updates automatically? I know I can download from insights but it’s still a very manual process for me filtering out the posts that I want.

    Thanks in advance!
    Ellie

    1. Hey Ellie,

      I don’t know a way to do this with these IMPORT formulas. They’re somewhat limited. You’ll need to look at using a third-party tool like supermetrics, or creating a script to talk to the api, to do this.

      Cheers,
      Ben

  67. Do you know if it is possible to show a youtube videos play count? I want to keep track of a number of videos in one sheet if possible.

    Thanks
    Andrew

  68. Hi Ben,

    This page is epic thank you!

    I’m having some trouble getting Twitter follower count to work.

    It works sometimes but I’m trying to find a way to populate it as 100,000 instead of 100k, 1,500,000 instead of 1.5m etc.

    Are there any solutions to display the actual follower count?

    Thank you

    1. Hey Jago,

      Use a quick substitute formula to do this, e.g.

      =SUBSTITUTE(B1,"M","")*1000000

      For a full example of how to incorporate with the IMPORT function, have a look at the Instagram section πŸ™‚

      Cheers,
      Ben

  69. How could I apply the same formula in each cell down the entire column without having to drag or copy the formula each time I add a row? Would it be something similar to …

    Facebook
    =ARRAYFORMULA(IFERROR((INDEX(SPLIT((INDEX(IMPORTXML(I2, “//div[contains(div, ‘follow this’)]”),13)), ” “), 1, 1)), “”))

    1. Hey Andy,

      I used to have a working Linkedin formula but it stopped working last time they updated their site. Haven’t found an alternative yet, will post it here if I do. I’ll add Flipboard to the shortlist for the future updates.

      Ben

  70. Hi Ben,

    As you know from many people thanking you this post is gold, you did an amazing job giving it free to us, thanks a lot.

    I have been using the instagram hashtag count for over a month and noticed that today the hashtag count stopped for hashtag that have less than a 20,000 (odd number I know).

    I can’t seem to understand why… Any idea?

    Tristan

    1. Hmm, not sure, it’s still working for me for accounts under 20k. You could try adding or removing a final back slash from the url ( “/” ) to force it to recalculate…

      Ben

  71. Hi Ben – trying to extract instagram followers into google sheets for quite a large group, about 1500 handles (all the accounts I follow) but the formula is delivering errors 90% of the time.

    Wondering if there is a computing power issue with doing this many, or if Instagram has changed their API? Can’t seem to identify why it works for some and not others – have checked all the instagram links to make sure they are current and working

  72. Also forgot to mention that the formula to correct 12.9k followers into number format is delivering some weird results.. e..g 12.9k has come up as the wrong number, 900 odd thousand?

  73. Hi Ben, awesome article! It helped me a lot!
    One question: Is it also possible to track Facebook Event Pages? So that Google Sheets will give me the number of people going/interested in an event? With your formula google sheets is only giving me the likes of a FB page..
    Maybe you can help me with that πŸ™‚ Thanks!

  74. Hi this is magic! I’m using it to count my Instagram followers on 6 accounts, but your Followers formula returns a X,XXX text which I cannot perform mathematical calculations on! The Following formula is fine. How do I modify the text to number? Formatting the cell doesn’t seem to work.

  75. Is it possible to use regex to crawl data that’s in a script? e.g. for Instagram – because you can get a lot more insights from that…

    window._sharedData = {“activity_counts”:

    “edge_followed_by”:{“count”:16931}

  76. Recently the Twitter’s Followers count is returning “#N/A”
    Any solution for that ? Earlier it was working fine.
    I have tried on different sheets but with no luck.
    Has twitter changed their webpage code ?

  77. This is seriously the IMPORTXML stat bible! πŸ˜›

    I’m having problems getting the Facebook like count to update. And it happens with some pages only for some reason.

    This works for instance (some times it returns #N/A though):
    =REGEXEXTRACT(SUBSTITUTE( IMPORTXML(“https://www.facebook.com/benlcollinsData”,”//meta[@name=’description’]/@content”),”,”,””),”\d{1,}\w{1,}\s\w{1,}”)

    But if I change to another page like “https://www.facebook.com/TappingIntoWealthCoachTraining” it always shows #N/A.

    Any ideas on what’s causing this and how to fix it?

    I’ve also experienced that a formula works in one Google Sheet, but when I copy it to another Google Sheet (editing the references of course), it shows #N/A.

  78. Hi Ben,

    I’ve been able to replicate and adapt your code regarding Twitter’s follower count and it works great, thanks a lot! I immediately decided to see if I could do this with followers name or bio, but I’m struggling to get a result.

    Am I doing something wrong?
    =query(IMPORTXML(“https://twitter.com/TwitterFrance/followers”,”//span[@class=’username u-dir'[1]”))

  79. Hi Ben, awesome article! Really helpful!

    One question: Is there a way to also extract the link to the businesses website using this method? I’m sure there is, I guess the problem are my XPath skills…

    Thanks,
    Niko

  80. I’ve looked at this article a thousand times, and thank you for all of it! But…I’m here with bad news. Looks like the Facebook formula isn’t working. It returns an error “Resource at url contents exceeded maximum size”, both on my sheet and yours.

  81. Hello πŸ™‚ I have kind of a specific question:

    Is there a way to build a script that calculates the average number Likes on a given Instagram Profile, then only selects posts that have more then average likes and sorts them by performance?

  82. Yeah if you take a look at the data returned from Facebook it seems they are now blocking these requests from Google sheets which is a huge shame.

  83. Hello Ben,
    Thanks a lot for your great article.
    We have tried the below formula to extract the followers from twitter for a particular page.
    cell.setFormula('=QUERY(IMPORTXML(\"'+url+'\","//a[@data-nav=\'followers\']"),"select Col3")');

    where url is the twitter page url

    It returns the value of followers of that page , as expected.
    But the value is incorrect . It is not exactly equal to the value in the twitter page.
    But when we inspected the twitter page in the browser , the particular html tag was actually showing the updated and correct value.
    Can you please help on this.

  84. Hello Ben,
    Thanks a lot for this awesome article
    The below code which I have tried is not showing updated/correct values for twitter followers count
    cell.setValue('=QUERY(IMPORTXML(\"'+url+'\","//a[@data-nav=\'followers\']"),"select Col3")');

    We also tried the random number parameter as a suffix to the url
    Even that didn’t help

    Can you please help on this

  85. Hey,

    thanks for updating the Facebook likes formula. It still seems a bit buggy since in some cases, the page just shows the text as:
    XXX people like this (e.g. https://mobile.facebook.com/aveeno/) – in this case, the formula works great and captures the number as XXX.

    However, in some cases, the page shows the number of likes as:
    John Doe and XXX people like this page (e.g. https://mobile.facebook.com/Eau.Thermale.Avene.Israel/?_rdr) – in this case, the formula breaks and captures only part of the number.

    Would be great if this can some how be fixed and shared everyone

    1. Hi,
      Got really excited that there was an update for the Facebook formula but it works for some pages, it doesn’t for others πŸ™
      Really looking forward for a new one, crossing fingers it won’t take long!
      Thank you to everyone making these super useful magic formulas work!

          1. Hey Clara, thanks for sharing that. I’ve updated the formula to account for this issue I hope. Turns out that some of the data comes back with 75k (or m for millions) which wasn’t being picked up. Any thousand or million numbers with the k or m abbreviations should be converted into full numbers now. Updated version of your spreadsheet here: https://docs.google.com/spreadsheets/d/11pBUM9bx3g1_yXYHESZWcBKe7YHbaqvy0iRYFub4OYY/edit?usp=sharing

            Cheers,
            Ben

  86. Hey, Ben!

    I can’t get the Instagram follower formula to work with large numbers (even the big one). Do you think you could take a look?

    Sometimes it gives out an error saying MULTIPLY parameter 1 expects numbers but got text instead.

    And sometimes it generates a wrong, much bigger number.

    I’ve used the following with B18 being the cell that contains https://www.instagram.com/mcdonalds/:

    =if(isnumber(search(“k”;REGEXEXTRACT(IMPORTXML(B18;”//meta[@name=’description’]/@content”);”(.{1,})(?: Followers)”)));substitute(REGEXEXTRACT(IMPORTXML(B18;”//meta[@name=’description’]/@content”);”(.{1,})(?: Followers)”);”k”;””)*1000;if(isnumber(search(“m”;REGEXEXTRACT(IMPORTXML(B18;”//meta[@name=’description’]/@content”);”(.{1,})(?: Followers)”)));substitute(REGEXEXTRACT(IMPORTXML(B18;”//meta[@name=’description’]/@content”);”(.{1,})(?: Followers)”);”m”;””)*1000000;REGEXEXTRACT(IMPORTXML(B18;”//meta[@name=’description’]/@content”);”(.{1,})(?: Followers)”)))

    For some reason the result is 43162000000 (they have many followers but not this many).

    Can you help? Thanks!

Leave a Reply

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