How to create an analytics dashboard for Quora

By Jonathan Nuñez

Table of Contents

Choosing the right questions to answer is essential to your success on Quora because it will allow you to focus on questions that are actually getting traffic.

Normally we would use a tool like Ahrefs for this but we know not everyone has access to paid tools (if you have a marketing budget, read this guide instead).

This script will help you create an analytics dashboard to get real-time data from Quora, that way you can make an informed decision as to which ones you should work on and which to avoid.

Ready?

Let’s start.

How to create an analytics dashboard for Quora

Before I start, I have to thank Yanir Calisar for creating the script, without him we wouldn’t be able to share this with you today.

Step 1: Open a new Google sheets document

To open a new Google sheet, all you have to do is click “New” to reveal the drop-down menu. Then click “Google sheets” to open a new document.

This image shows you how to open a new Google sheet
Creating a new Google sheet

Step 2: Open the script editor

To open the script editor, click on “tools” to reveal the drop-down menu. Then select “script editor”.

This images shows you how to open the script editor
How to open the script editor

Step 3: Disabling Chrome V8

If you are greeted with the message “This project is running on our new Apps Script runtime powered by Chrome V8” when you open the script editor, disable it. If you don’t, the script won’t work.

Chrome V8 message

To disable Chrome V8…

  1. Click “run” to reveal the drop-down menu.
  2. Click “disable new Apps Script runtime powered by Chrome V8”.
This image shows how to disable Chrome V8
How to disable Chrome V8

Step 4: Selecting a name for the project

Write a name for your project. I recommend “Quora Script” so you can easily recognize it.

Step 5: Adding the Quora script

Delete the existing code on the page.

Then copy the complete and exact code below to the page. Don’t change anything or the script won’t work.

5.1 Script Code:

Copy the script

Select all the text in the box below, right click the selected area to open the options menu, and then click "copy" to add it to your clipboard. After that, go back to the script editor, right click the white area, and then click "paste".

/* Imports Quora stats to your spreadsheet Ex: quora(“https://www.quora.com/What-is-Quora-112”)

* @param url URL of your Quora page as string

* @customfunction

*/

var headers = {

    “user-agent”: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36”,

    “sec-fetch-user”: “?1”,

    “sec-fetch-site”:”cross-site”,

    “upgrade-insecure-requests”: 1,

    “pragma”: “no-cache”

};

var options =  {

    “method” : “get”,

    “muteHttpExceptions”: true,

    “headers”: headers

};

//the function that exposed in the sheet

function quora(url) {

    var vals = [];

    //validate that it’s a quora url

    if(url !== undefined && url.indexOf(“quora.com”) > 0) {

        //wait for the page to load, otherwise quora returns 403

        Utilities.sleep(1000);

        var res = UrlFetchApp.fetch(url + “?” + new Date().getDate(), options);

        var content = res.getContentText();

        var xmldoc = Xml.parse(content, true);

        //getting the question (page title)

        var title = getTitle(xmldoc, content);

        //if question and title exist, get the other stats

        if (title && title.length > 0) {

            vals.push(url);

            vals.push(title);

            vals.push(getTopics(content));

            vals.push(parseInt(getAnswers(content)));

            //read the question’s logs page

            var logs = getLogs(url);

            vals.push(logs.views);

            vals.push(logs.followers);

            return [vals];

        } else {

            return [[“Failed to get data! Check your link.”]];

        }

    }else

        return [[“Please provide a valid link to some Quora question”]];

}

function getTitle(xmldoc, content){

    try{

        var t = “unknown!”;

        var elm = xmldoc && xmldoc.html && xmldoc.html.head ? xmldoc.html.head.getElements(“title”) : “”;

        if(elm.length > 0){

            t = elm[0].getText();

        }else{

            var c = content.substring(content.indexOf(“h1>”),content.indexOf(“h1>”) + 50);

            t = c;

        }

        return t.replace(” – Quora”,””).replace(/”/g, “‘”);

//        return [0].getText().replace(” – Quora”,””).replace(/”/g, “‘”);

    }catch(e){

        return “unknown”;

    }

}

function getLogs(url){

    url = removeLastSlashIfExists(url) + “/log” + “?” + new Date().getDate();

    Utilities.sleep(1000);

    var html = UrlFetchApp.fetch(url, options).getContentText();

    html = html && html.length > 1000 ? html.substring(html.indexOf(“QuestionStats”),html.length) : html;

    var data = {

        views: parseInt(getViews(html)),

        followers: parseInt(getFollowers(html))

    };

    return data;

}

function getTopics(html){

    try{

        var txt = “”;

        var elms = html.substring(html.indexOf(“QuestionTopicListItems”) + 20,html.indexOf(“QuestionTopicListItems”) + 3000).split(“TopicNameSpan”);

        for(var i =1; i < elms.length; i ++){

            var e = elms[i];

            txt += e.substring(e.indexOf(“>”) + 1, e.indexOf(“<“));

            if(i < elms.length -1)

                txt += “, “;

        }

        return txt;

    }catch(e){

        return 0;

    }

}

function getAnswers(html){

    try{

        var str = html.substring(html.indexOf(“answer_count”) + 10,html.indexOf(“answer_count”) + 30 ).replace(/\D/g,”);

        if(str === 100){

            return “100+”;

        }else if(str.length > 0){

            return str;

        }else{

            return “0”;

        }

    }catch(e){

        return 0;

    }

}

function getViews(html){

    try{

        var e = html.substring(html.indexOf(” Views”) – 10,html.indexOf(” Views”) ).replace(/\D/g,”);

        e = e.length > 0 ? e : “0”;

        return e;

    }catch(e){

        return 0;

    }

}

function getFollowers(html){

    try{

        var e = html.substring(html.indexOf(“Public Followers”) – 10, html.indexOf(“Public Followers”) ).replace(/\D/g,”);

        e = e.length > 0 ? e : “0”;

        return e;

    }catch(e){

        return 0;

    }

}

function removeLastSlashIfExists(url){

    var slash = url.substring(url.length -1, url.length);

    if(slash === “/”){

        return url.substring(0, url.length -1);

    }

    else return url;

}

After you finish copying the code, it should look like this. ↓

Step 6: Saving your project

Click here to save the script.

How to save your Quora script

Then close the script editor and go back to the Google sheet.

Step 7: Setting up the Google sheet

On the Google sheet, write the following in the first row.

Cell A1: URL
Cell B1: Question
Cell C1: Topics
Cell D1: Answers
Cell E1: Views
Cell F1: Followers

It should look something like this. ↓

First row of the spreadsheet

Those are the cells that will be autocompleted by the script and are essential for it to work.

7.1 Adding extra columns

The next columns are to get feedback from our team members. This is where they are going to tell us which questions to work on and any notes they may have.

On cell …

  • G1, write Approved
  • H1, write Answered
  • I1, write Status
  • J1, write Notes

7.2 Editing the sheet

This is the “technical” part of the guide. The first thing to do is click on the G column to automatically select all cells in that column. Then hold “column” + “click” the G1 cell to deselect it.

How to select a complete column in Google sheets
How to select a complete column in Google sheets

After that, go to the main menu and click on “Data” to reveal the dropdown menu. Then click on “Data validation”.

This picture shows you how to open data validation
How to open data validation

When the new window opens, under “Criteria”, click on the box that says, “List from a range”. That will open a drop-down menu.

Click the last option (Checkbox).

Then click the box “Use custom cell values”.

After that, on “Checked” type “Yes” and on “Unchecked” type “No”.

Data validation - custom cells

Then click “Save”.

Repeat the same process as in Column G for the Answered column (H). After you finish doing that, it should look like this. ↓

7.2.1 Editing column I

This step is similar to the two previous ones. The main difference is in the input. Just like on the G column, select column I to automatically select all cells in that column. Then hold “column” + “click” the I1 cell to deselect it.

This image shows you how to select all cells in a column
How to select all cells in a column

After that, go to the main menu and click “Data” to reveal the drop-down menu. Then click on “Data validation”.

This picture shows you how to open data validation
How to open data validation

When the new window opens, under “Criteria”, click on the box that says, “List from a range”. That will open a drop-down menu.

Then select the option “List of items”.

How to add a list of items on Google sheets
How to add a list of items on Google sheets

After that, enter the text below on the section that says, ”Enter items separated by a comma”.

Approved,Added to workload,In development,Completed,Under review,Ready to publish,Published

Just copy and paste the text to do it faster.

Then under “On invalid data” select the option “Reject input”.

How to add a list of items on Google sheets
How to add a list of items on Google sheets

Click the box that says ”Show validation help text”.

And lastly, click “Save”.

How to add a list of items on Google sheets
How to add a list of items on Google sheets

Here’s the final result. ↓

How to add a list of items on Google sheets
How to add a list of items on Google sheets

The Notes column is so your teammates can provide detailed feedback like the approach they want you to take, if there’s anything specific they want you to mention, etc.

Step 8: Adding links to the Google sheet

Adding links is simple. All you have to do is open the spreadsheet you downloaded from Ahrefs and copy and paste all links to the new google sheet. After you do that, all you have to do is add the code.

8.1 Adding the code

After you add all links, type in the code =quora(“link”). Do this for all links you have in the spreadsheet. Here’s an example of what it looks like and how to use it. ↓

Structure of a link to trigger the script
Structure of a link to trigger the script

After that, the script will kick in and automatically start pulling data from Quora.

It's your turn

Create your own analytics dashboard on Google sheets and choose the best questions to answer on Quora.

If you have any questions, make sure to let us know in the comment section below and we’ll do our best to help you. 🙂

1 Comment

  • I am extremely impressed together with your writing talents and also with the format to your blog. Is that this a paid subject matter or did you modify it yourself? Anyway keep up the excellent quality writing, it’s uncommon to see a nice weblog like this one today.

Leave a Reply

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