RevenueCat to Google Sheets: how to connect your metrics
Connect RevenueCat to Google Sheets with a working Apps Script example, schedule refreshes and choose CSV exports or webhooks when you need different data.
By AppCradle · Published

You can connect RevenueCat to Google Sheets by calling the RevenueCat API from Google Apps Script and writing the response into a worksheet. For a small team that wants a refreshable subscription overview, this is a straightforward starting point: one private script, one read-only API key and one destination spreadsheet.
This tutorial builds a latest-snapshot report. It replaces the imported metrics on each successful run rather than appending duplicate rows. It does not export every subscriber, reconstruct transaction history or calculate bank payouts.
The code below is an original example checked against the documented APIs and tested with mocked responses. You still need to run and authorize it in your own Google account, then reconcile its output with your RevenueCat project before relying on the report.
Choose the data you need before connecting
“RevenueCat to Google Sheets” can mean three different workflows. Pick the one that matches the question you want the spreadsheet to answer.
| Your question | Starting point | What to expect |
|---|---|---|
| What does our subscription overview look like now? | API snapshot with Apps Script, shown below | A refreshable table of aggregate metrics |
| Which transactions contributed to a report? | Scheduled Data Exports, then a controlled CSV import | Exported records that need reconciliation and update handling |
| What changed when a subscription event occurred? | Webhooks through an authenticated receiver | An event log requiring deduplication and delivery monitoring |
Start with the overview if your goal is a management report. An event stream and an aggregate snapshot are not interchangeable: counting renewal notifications will not reproduce every RevenueCat reporting definition.
1. Prepare a dedicated RevenueCat key
You need access to the relevant RevenueCat project and permission to create a secret API key. In the project's API keys settings, create a V2 secret key for this report. A public SDK key is not the credential for this connection. Keep the secret out of spreadsheet cells, formulas and shared source files. RevenueCat's API key documentation explains the distinction and how to revoke a key.
Grant charts_metrics:overview:read for the overview endpoint used here. Copy your Project ID from the project's settings, not an App ID, store ID or bundle identifier. The request is:
GET https://api.revenuecat.com/v2/projects/{project_id}/metrics/overview?currency=USD
The Charts & Metrics API reference documents that endpoint, its permission and response fields. This example explicitly requests USD and preserves each metric's unit, period and provider update time. It does not request app-level filters or a historical date range.
Use a dedicated credential so you can rotate or revoke this report's access without changing the credentials used by another integration.
2. Create the spreadsheet and a private script
Create a new Google spreadsheet for the report. Copy the spreadsheet ID from its URL: it is the value between /d/ and /edit, not the gid identifying a tab.
Create a standalone Apps Script project at script.google.com, using a Google account that can edit the destination spreadsheet. A standalone project can run independently of the spreadsheet; Google's standalone script guide covers this setup.
Keep the script project private to the people who maintain the connection. Sharing the report should be a separate decision from sharing the script and its credential. Script Properties are configuration storage, not a secret vault that hides values from script editors.
Open Project Settings → Script Properties and add these three entries:
| Property | Value |
|---|---|
RC_API_KEY | Your dedicated RevenueCat V2 secret key |
RC_PROJECT_ID | The RevenueCat Project ID |
SHEET_ID | The destination spreadsheet ID |
Save the properties. Google's Properties Service guide documents this settings interface and the script-level property store.
The example owns a tab named RevenueCat Latest and writes columns A through J. Keep manual notes, formulas and charts on other tabs. If that name already contains work, use a new spreadsheet or change tabName in the code first.
3. Paste the Apps Script connector
Replace the starter function in the script editor with this code and save the project. You do not need to publish a web app or expose an inbound webhook URL for this scheduled API pull.
function refreshRevenueCatOverview() {
const lock = LockService.getScriptLock();
if (!lock.tryLock(1000)) throw new Error('Another refresh is running.');
try {
const config = PropertiesService.getScriptProperties().getProperties();
const required = ['RC_API_KEY', 'RC_PROJECT_ID', 'SHEET_ID'];
if (required.some(key => !config[key] || !config[key].trim())) {
throw new Error('Set RC_API_KEY, RC_PROJECT_ID and SHEET_ID first.');
}
const currency = 'USD';
const tabName = 'RevenueCat Latest';
const projectId = config.RC_PROJECT_ID.trim();
const url = 'https://api.revenuecat.com/v2/projects/'
+ encodeURIComponent(projectId)
+ '/metrics/overview?currency=' + currency;
const response = UrlFetchApp.fetch(url, {
method: 'get',
headers: {
Authorization: 'Bearer ' + config.RC_API_KEY.trim(),
Accept: 'application/json'
},
muteHttpExceptions: true,
followRedirects: false
});
if (response.getResponseCode() !== 200) {
throw new Error('RevenueCat HTTP ' + response.getResponseCode()
+ '. Previous sheet data was not replaced.');
}
const payload = JSON.parse(response.getContentText());
if (!payload || payload.object !== 'overview_metrics'
|| payload.currency !== currency
|| !Array.isArray(payload.metrics) || !payload.metrics.length) {
throw new Error('Unexpected overview response; no data written.');
}
const fetchedAt = new Date().toISOString();
const text = value => /^[=+@\-\s]/.test(value) ? "'" + value : value;
const seen = new Set();
const rows = payload.metrics.map(metric => {
if (!metric || ['id', 'name', 'unit', 'period', 'description']
.some(key => typeof metric[key] !== 'string')
|| !metric.id || seen.has(metric.id)
|| typeof metric.value !== 'number' || !Number.isFinite(metric.value)) {
throw new Error('Invalid or duplicate metric; no data written.');
}
seen.add(metric.id);
let updatedAt = '';
if (metric.last_updated_at !== null) {
if (!Number.isSafeInteger(metric.last_updated_at)
|| metric.last_updated_at < 0) {
throw new Error('Invalid provider timestamp; no data written.');
}
updatedAt = new Date(metric.last_updated_at).toISOString();
}
return [fetchedAt, text(projectId), text(metric.id), text(metric.name),
metric.value, text(metric.unit), text(metric.period), currency,
updatedAt, text(metric.description)];
});
const values = [[
'fetched_at_utc', 'project_id', 'metric_id', 'metric_name', 'value',
'unit', 'period', 'currency', 'source_updated_at_utc', 'description'
], ...rows];
const spreadsheet = SpreadsheetApp.openById(config.SHEET_ID.trim());
const sheet = spreadsheet.getSheetByName(tabName)
|| spreadsheet.insertSheet(tabName);
const rowCount = Math.max(values.length, sheet.getLastRow());
while (values.length < rowCount) values.push(Array(10).fill(''));
if (rowCount > sheet.getMaxRows()) {
sheet.insertRowsAfter(sheet.getMaxRows(), rowCount - sheet.getMaxRows());
}
sheet.getRange(1, 1, rowCount, 10).setValues(values);
SpreadsheetApp.flush();
} finally {
lock.releaseLock();
}
}
The connector fetches and validates the complete response before writing any metric cells. It retains numeric zero, leaves an unknown provider timestamp blank and rejects malformed data instead of manufacturing missing values. It also clears obsolete trailing rows inside its output range when a later response contains fewer metrics.
The script lock prevents overlapping executions of this project; it does not stop someone manually editing the output tab or another script writing to it. Google documents script locks, authenticated HTTP requests with UrlFetchApp and writing rectangular ranges with setValues. The text escaping prevents imported text from becoming a spreadsheet formula.
4. Run once and validate the result
Choose refreshRevenueCatOverview in the function selector and click Run. Review Google's authorization prompt for spreadsheet access and external requests. If your organization blocks the permissions, ask its administrator to review the script rather than changing account controls. Google's authorization guide explains why the first run requires consent.
Open RevenueCat Latest. You should see a header row and one row for each returned metric, with a common fetch timestamp. Verify the project, currency and relevant dashboard scope before comparing values.
RevenueCat describes overview MRR as a current monthly run rate, while its overview revenue covers the last 28 days. Dashboard dates use UTC unless otherwise specified. Read the overview metric definitions. Keep the returned period and description beside each value rather than renaming all figures “monthly revenue.”
Check these four things before scheduling:
- Compare several imported values with the corresponding RevenueCat overview cards, allowing for the recorded data freshness and matching the relevant dashboard settings.
- Run the function again. It should refresh the existing table rather than append another copy of the same metrics.
- Confirm
source_updated_at_utcseparately fromfetched_at_utc. A successful fetch does not prove that the underlying metrics were recomputed at that moment. - Temporarily use an invalid key in this dedicated test setup. The run should fail and leave the previous metric cells unchanged. Restore the valid key afterward.
A missing metric is not zero revenue. A blank provider timestamp means the API did not supply an update time. Record either limitation in the report you share.
5. Schedule the refresh
In the Apps Script editor, open Triggers, add a trigger for refreshRevenueCatOverview, choose Time-driven and select a daily interval. Check the project's time zone and choose a reporting window that suits your team. Start with one trigger; do not create another each time you test the function.
Installable triggers run under the account that created them. Google can vary execution time within the selected window, so this is not an exact-to-the-minute reporting service. Review Executions and configure the available failure notifications. Google's installable trigger documentation describes scheduling, ownership and failure handling.
Name an owner for the connection. When that person loses access, the key is revoked or the spreadsheet moves, someone needs to repair and revalidate the report. Monitor both failed executions and stale fetch timestamps; an old table can still look convincing after refreshes stop.
This example replaces the latest snapshot. If you need a historical series, design a separate archive with explicit snapshot dates, unique keys and correction handling, or query the appropriate reporting endpoint. Do not add overlapping rolling-period totals together to create a monthly total.
Troubleshoot the connection
| Symptom | What to check |
|---|---|
| Missing configuration error | The three Script Property names and their saved values |
| HTTP 401 | Whether the key is valid, unrevoked and a V2 secret key |
| HTTP 403 | The overview read permission and access to the requested project |
| HTTP 404 | The Project ID and endpoint path; do not substitute an App ID |
| HTTP 429 | Reduce refresh frequency, remove duplicate triggers and respect the API's retry guidance |
| JSON or schema error | Inspect the response safely and compare it with the current API reference; do not log the key |
| Google permission or spreadsheet error | The trigger owner's authorization and edit access to the destination |
| Successful run but old source data | Compare fetch time with provider update time before reporting a change |
The example deliberately stops on an HTTP error rather than entering an unbounded retry loop. The previous table is useful only when its age remains visible. A Google Sheets write failure should also be investigated in Executions; the script does not claim transactional recovery across services.
Apps Script has account-dependent quotas and runtime limits. Check the current Google limits before expanding the script to many projects or frequent refreshes. For a larger reporting pipeline, move ingestion into a monitored service and publish only the report output to Sheets.
When CSV exports or webhooks are a better fit
For transaction analysis, consider RevenueCat Scheduled Data Exports. They support scheduled delivery to cloud storage or email, with selectable feeds and columns. Check eligibility and choose CSV when your next step is a spreadsheet import.
For a first review, download a CSV from your configured destination and import it into a new Google Sheets tab using File → Import → Upload, following Google's file import instructions. Record its export time and covered period. This is a manual import, not an automatic connection. Recurring ingestion needs a separate job that reads new exports and handles updates to previously seen records; blindly appending every file can duplicate overlapping data.
For an event log, RevenueCat can POST subscription events to a receiver you configure. Validate the configured authorization header, deduplicate by event ID and monitor downstream writes before using those events in a worksheet. See the webhook setup documentation. Historical subscription changes do not produce a complete historical event stream through integrations, so plan backfills separately. RevenueCat explains historical event behavior here.
Avoid putting customer-level payloads into a broadly shared financial report. If you need individual records for support or investigation, define the audience and retention separately from the aggregate overview.
Keep the spreadsheet useful as reporting grows
Create a presentation tab that references metric IDs rather than assuming MRR will always occupy the same row. Display the currency and freshness alongside the headline numbers. Keep API output separate from formulas so a refresh cannot overwrite your analysis.
Do not add RevenueCat revenue to App Store or Google Play totals covering the same purchases. Our guide to differences between app revenue reports explains how to compare scope and definitions. For payment reconciliation, also distinguish sales, proceeds and bank receipts with the App Store sales versus proceeds guide.
If your goal is a maintained subscription reporting workspace rather than a custom spreadsheet, see AppCradle's RevenueCat integration guide. It describes AppCradle's reporting connection; it does not turn the Apps Script example into an AppCradle-to-Sheets sync.
A useful first deliverable is small: one verified project, one latest-metrics tab, one refresh owner and a visible timestamp. Add history or event-level detail only when the reporting question requires it.
See the bigger picture.
Bring your store reports together and spend more time understanding what they mean.
Try for free