# Google Sheets and Looker Studio

> Put Datacenter numbers in Google Sheets with one formula that refreshes by itself, then chart them in Looker Studio.

Source: https://datacenter.so/docs/looker-studio
Section: Developers

Every list in the [read API](https://datacenter.so/docs/api) has a CSV feed. Google Sheets reads a feed with one formula and refreshes it by itself, and Looker Studio charts any sheet. That is the path today.

A Datacenter connector for Looker Studio (when shipped) will let you pick a site and a report inside Looker Studio, with no sheet in between.

CSV feeds are on paid plans: Solo, Studio, Agency and Custom.

## 1. Make a key for one site

Open **Settings**, then **API**. Under **Reads**, pick the site, name the key (for example "Sheets") and press **Make a key**. Copy it.

A feed address holds the key, and Google fetches it from its own servers. Anyone who sees the formula can read that site. A key for one site keeps that small, and **Revoke** stops it at once.

## 2. Find the site id

The site's dashboard address ends with it: `app.datacenter.so/s/3f9a1c2e7b4d8a06` has the id `3f9a1c2e7b4d8a06`.

## 3. Add a feed to Google Sheets

In an empty sheet, click cell A1 and paste a formula. Put your site id and key in.

Visitors per day for the last 90 days:

```text
=IMPORTDATA("https://datacenter.so/api/v1/sites/3f9a1c2e7b4d8a06/timeseries?period=90d&format=csv&key=st_rk_...")
```

Top sources this month:

```text
=IMPORTDATA("https://datacenter.so/api/v1/sites/3f9a1c2e7b4d8a06/breakdown/source?period=mtd&format=csv&key=st_rk_...")
```

More feeds, all with `&format=csv&key=st_rk_...` at the end:

| Feed | Address after `https://datacenter.so` |
|---|---|
| Totals for a range, one row | `/api/v1/sites/SITE_ID/stats?period=30d` |
| Per day, hour or month | `/api/v1/sites/SITE_ID/timeseries?period=90d&interval=day` |
| Top pages | `/api/v1/sites/SITE_ID/breakdown/page?period=30d` |
| Campaigns | `/api/v1/sites/SITE_ID/breakdown/campaign?period=30d` |
| Countries or devices | `/api/v1/sites/SITE_ID/breakdown/country?period=30d` |
| Goals | `/api/v1/sites/SITE_ID/goals?period=30d` |
| Sales credited by campaign | `/api/v1/sites/SITE_ID/attribution?period=30d&by=campaign` |
| Ad spend and ROAS by campaign | `/api/v1/sites/SITE_ID/ads?period=30d&level=campaign` |
| Short link clicks | `/api/v1/links?period=30d` |

Money feeds have one currency column. Add `&currency=EUR` to pick it; by default it is the one with the most money.

Google Sheets refreshes these formulas on its own, about once an hour. Put each feed on its own tab, so they never overlap.

## 4. Chart it in Looker Studio

1. In [Looker Studio](https://lookerstudio.google.com), create a report and choose **Add data**.
2. Pick **Google Sheets**, then your sheet and the tab with the feed.
3. Keep **Use first row as headers** on and press **Add**.
4. Check that `date` reads as a date: in the data source, set its type to **Date** if Looker Studio did not.

Charts update when the sheet does.

## Good to know

- Feed numbers are the same as the dashboard's: whole days in the site's time zone. Add `&timezone=America/New_York` to read them in another.
- A feed holds up to 1,000 rows.
- Each refresh counts toward the key's 120 requests a minute.
- If a feed stops, the cell shows an error. A revoked key or a plan change is the usual reason.
