Google Analytics

(David) #1

Hi - I’m wondering if there’s a way to connect to the reporting data inside Discourse’s dashboard? I’d like to build a dashboard that includes some of the metrics / data that isn’t available via Google Analytics, such as likes, comments, topics, posts, etc…

Specifically, is there a way to pull this data into a google sheet?

Alternatively, do you know if this data is accessible somehow via google analytics?

(Bas van Leeuwen) #2

Hi David,

You could take a look at Community Analytics or DiscourseMetrics which do a lot of these things for you.

Happy to answer any questions about the former, since – disclaimer – I built that Community Analytics one with a friend of mine.

And I’m pretty sure is happy to answer any questions about … DiscourseMetrics :slight_smile:

(David) #3

Hey - thanks for the reply Bas. I’m aware of those but I’m just trying to get access to the data in order to create my own dashboards. My goal is to sync up a few data sources into one dashboard to look at data holistically across a few channels, domains, etc…

The easiest way to do this is to have the data feed into a google sheet. Do you know how I might do that?

(Bas van Leeuwen) #4

Ah, that’ll require some json and Google app script trickery :slight_smile:

You can get the data in json from here:

Here’s an example: Discourse stats example - Google Sheets

Use this (or prettier, this is just a quick fix) code in the google script:

function discourseStats(url) {
  var url = url||'';
  url = url + '/about.json';
  var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
  var data = JSON.parse(response);
  var stats = data.about.stats; 
  var array = []
  for (key in stats){
    array.push([key, stats[key]])
  return array;