# إضافة جمع المقاييس الآلية باستخدام Zapier

**URL:** <https://meta.discourse.org/t/add-automated-metrics-collection-with-zapier/52519>\
**Category:** Administrators\
**Tags:** how-to, tasks, zapier\
**Created:** [4 نوفمبر 2016، 8:04م UTC](https://meta.discourse.org/t/add-automated-metrics-collection-with-zapier/52519 "2016-11-04T20:04:05Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![slagle](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@slagle](https://meta.discourse.org/u/slagle)\
**Post date:** [4 نوفمبر 2016، 8:04م UTC](https://meta.discourse.org/t/add-automated-metrics-collection-with-zapier/52519/1 "2016-11-04T20:04:05Z")

</div>

Hey guys and gals!

I wanted to share with you all a way that I have been using to automate our metrics collection. I am using Zapier to do all of it and it has greatly simplified my life. 🙂

Anyways, since Zapier allows Multi-Step" zaps I am able to make a call into our site and pull json for each of the metrics I care about and then add them straight to a Google Sheets spreadsheet using Zapier. I then usee Google Data Studio to display the results.

Zapier has a action called “Code by Zapier” that allows you to run some short NodeJS scripts that can do anything you want really. So I use it to make a get request to the JSON pages for each of the metrics I track.

It looks something like this:

```
fetch('https://YOUR_ROOT_SITE_HERE/admin/reports/visits.json?api_key=YOUR_API_KEY_HERE')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json.report.data[json.report.data.length - 2]);
  })
  .catch(callback);

```

I then am able to take the data from the response and put it into a google sheet. Pretty simple really. 🙂

* * *

Here are my code samples for each metric that I pull. Each one pulls the previous day’s data.

**User Visits:**

```
fetch('https://YOUR_ROOT_SITE_HERE/admin/reports/visits.json?api_key=YOUR_API_KEY_HERE')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json.report.data[json.report.data.length - 2]);
  })
  .catch(callback);

```

**New Sign-Ups:**

```
fetch('https://YOUR_ROOT_SITE_HERE/admin/reports/signups.json?api_key=YOUR_API_KEY_HERE')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json.report.data[json.report.data.length - 2]);
  })
  .catch(callback);

```

**New Topics:**

```
fetch('https://YOUR_ROOT_SITE_HERE/admin/reports/topics.json?api_key=YOUR_API_KEY_HERE')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json.report.data[json.report.data.length - 2]);
  })
  .catch(callback);

```

**New Posts:**

```
fetch('https://YOUR_ROOT_SITE_HERE/admin/reports/posts.json?api_key=YOUR_API_KEY_HERE')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json.report.data[json.report.data.length - 2]);
  })
  .catch(callback);

```

---

_[View the full topic](https://meta.discourse.org/t/add-automated-metrics-collection-with-zapier/52519)._
