Pulling your DEV Organization Stats into a Spreadsheet
Tags: tutorial, showdev, productivity, beginners
Published: 2020-02-20 16:04:10

---
title: Pulling your DEV Organization Stats into a Spreadsheet
published: true
description: 
tags: #tutorial, #showdev, #productivity, #beginners
---

If you want to pull your stats for a personal account for DEV it's easy to do so since DEV has an API and there is already this great tutorial on how to do so, but how do you do the same if you're a DEV Organization?
{% link https://dev.to/pluralsight/pulling-your-dev-to-stats-into-a-google-sheet-56dh %}

There is no API at the Organization level but we can still get our data through a simple scraper which I wrote. All you have to do is navigate to your Organization's Dashboard.

Your Dashboard is not the same as your public-facing page, just make sure you're on the page that looks like this:
```
https://dev.to/dashboard/organization/ORG_ID>
```

1. Open Chrome
1. Go to your Organization's Dashboard
1. Open up Chrome Developer Tools
1. Paste in the code below and it will automatically download a CSV for all visible stats.
1. Enjoy reviewing your data

```js
function articles(){
	const results = []
	const articles = document.querySelectorAll('.single-article')
	let data;
	for(let i = 0; i < articles.length; i++){
		data = article(articles[i])
		if (data) {
			results.push(data)
		}
	}
	return results
}

function article(article){
	// if there is no time selector that means this article 
	// is not published and will have no useful stats
	if (article.querySelector('time')){
		const name = article.querySelector('h2').innerText
		const tags = article.querySelectorAll('.tag')
		const author = article.querySelector('option[selected=selected]').innerText
		const date = article.querySelector('time').innerText
		const page_view_count = article.querySelector('.page-views-count').innerText
		const reactions_count = article.querySelector('.reactions-count').innerText
		const comments_count = article.querySelector('.comments-count').innerText
		const tags_string = []	
		for(let t = 0; t < tags.length; t++){
			tags_string.push(tags[t].innerText)
		}	
		return [
			name,
			tags_string.join(' '),
			author,
			date,
			page_view_count,
			reactions_count,
			comments_count
		]
	} else {
		return false		
	}
}

function save_data(){
	const results = articles()
	results.unshift(['Name','Tags','Author','Date','Page Views Count','Reactions Count','Comments Count'])

	const csv_string = []
	for(let i = 0; i < results.length; i++){
		csv_string.push(results[i].join(','))
	}

  var blob = new Blob([csv_string.join("\n")], {type: 'text/csv'})
  let e    = document.createEvent('MouseEvents')
  let a    = document.createElement('a')
  const date = new Date().getTime()
  const epoch = Math.round(date / 1000)

  a.download = `export-${epoch}.csv`
  a.href = window.URL.createObjectURL(blob)
  a.dataset.downloadurl =  ['text/csv', a.download, a.href].join(':')
  e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
  a.dispatchEvent(e)
}

save_data()
```

The only downside is if the HTML markup changes it could break this scraper and minor changes will need to be made in order to fix this script.

I could see this script being packaged into a chrome extension which could pull daily, push it to a google spreadsheet and show you growth over time.