Visualise Antlytics data in Looker Studio
Looker Studio (formerly Google Data Studio) can connect to Antlytics via a community connector built with Apps Script, or via a Google Sheets data source you populate with the Antlytics API.
Option A: Google Sheets as an intermediary (easiest)
- Follow the Google Sheets guide to log daily stats to a sheet automatically.
- In Looker Studio, click + Create → Data source.
- Choose Google Sheets, select your spreadsheet and sheet, then click Connect.
- Build your charts using the
Date,Visitors,Pageviews, andBounce ratedimensions.
This approach updates daily (or however often your Apps Script trigger runs).
Option B: Custom community connector (Apps Script)
Build a Looker Studio community connector that calls the Antlytics API directly. This enables date-range filtering and live data.
Connector scaffold
// Code.gs — Looker Studio community connector for Antlytics
const cc = DataStudioApp.createCommunityConnector();
function getAuthType() {
return cc.newAuthTypeResponse().setAuthType(cc.AuthType.NONE).build();
}
function getConfig(request) {
const config = cc.newConfig();
config.newTextInput()
.setId('siteId')
.setName('Site ID')
.setHelpText('Found in Antlytics Settings → Tracking Snippet');
config.newTextInput()
.setId('apiToken')
.setName('API Token')
.setHelpText('Create one in Antlytics Settings → API tokens');
return config.build();
}
function getSchema(request) {
const fields = cc.getFields();
fields.newDimension().setId('date').setName('Date').setType(cc.FieldType.YEAR_MONTH_DAY);
fields.newMetric().setId('visitors').setName('Visitors').setType(cc.FieldType.NUMBER);
fields.newMetric().setId('pageviews').setName('Pageviews').setType(cc.FieldType.NUMBER);
fields.newMetric().setId('bounce_rate').setName('Bounce rate (%)').setType(cc.FieldType.NUMBER);
return { schema: fields.build() };
}
function getData(request) {
const { siteId, apiToken } = request.configParams;
const { startDate, endDate } = request.dateRange;
const url = `https://www.antlytics.com/api/v1/stats?site_id=${siteId}&from=${startDate}T00:00:00Z&to=${endDate}T23:59:59Z`;
const res = UrlFetchApp.fetch(url, {
headers: { Authorization: `Bearer ${apiToken}` },
muteHttpExceptions: true,
});
const { visitors, pageviews, bounce_rate } = JSON.parse(res.getContentText());
const fields = cc.getFields();
return {
schema: request.fields.map((f) => fields.getFieldById(f.name)),
rows: [{ values: [startDate.replace(/-/g, ''), visitors, pageviews, bounce_rate] }],
};
}
Deploy and connect
- Open the Apps Script project → Deploy → New deployment → Web app.
- Set Execute as: Me and Who has access: Anyone.
- Copy the deployment URL.
- In Looker Studio → + Create → Data source → Build your own → paste the URL.
Need help?
Email support@antlytics.com with your site ID.
Something missing? Get in touch and we will update these docs.