Antlytics logoAntlytics

Send Antlytics data to Google Sheets

Log your daily Antlytics stats to a Google Sheet for historical tracking, custom charts, and team reporting.

Option A: Apps Script (no third-party tools)

Google Apps Script can call the Antlytics API on a daily schedule.

Setup

  1. Open a Google Sheet → Extensions → Apps Script.
  2. Replace the default code with the script below.
  3. Replace YOUR_API_TOKEN and YOUR_SITE_ID with values from Settings → API tokens and your site's tracking ID.
  4. Run setupTrigger() once to register the daily trigger.
const API_TOKEN = 'ant_YOUR_API_TOKEN';
const SITE_ID  = 'YOUR_SITE_ID';

function fetchStats() {
  const url = `https://www.antlytics.com/api/v1/stats?site_id=${SITE_ID}`;
  const res = UrlFetchApp.fetch(url, {
    headers: { Authorization: `Bearer ${API_TOKEN}` },
    muteHttpExceptions: true,
  });
  if (res.getResponseCode() !== 200) {
    console.error('API error:', res.getContentText());
    return;
  }
  const { visitors, pageviews, bounce_rate } = JSON.parse(res.getContentText());
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  if (sheet.getLastRow() === 0) {
    sheet.appendRow(['Date', 'Visitors', 'Pageviews', 'Bounce rate (%)']);
  }
  const today = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'yyyy-MM-dd');
  sheet.appendRow([today, visitors, pageviews, bounce_rate]);
}

function setupTrigger() {
  ScriptApp.newTrigger('fetchStats')
    .timeBased()
    .everyDays(1)
    .atHour(9)
    .create();
}
  1. Click Run → fetchStats once to add today's row and verify permissions.

Option B: Via Zapier or Make

For a no-code approach, use Zapier or Make:

  1. Connect Antlytics to Zapier/Make via Settings → Webhooks.
  2. Add a Google Sheets → Create Spreadsheet Row action.
  3. Map period, stats.visitors, stats.pageviews, and stats.bounce_rate to columns.

Need help?

Email support@antlytics.com with your site ID.

Something missing? Get in touch and we will update these docs.