Skip to main content
RapidDev - Software Development Agency
retool-integrationsRetool Native Resource

How to Integrate Retool with Google Analytics

Connect Retool to Google Analytics using the native Google Analytics Resource, authenticated via Google OAuth. Once configured, write GA4 reporting API queries to pull sessions, users, conversions, and custom dimensions into Retool Chart and Table components. You can combine web analytics data with revenue or support data from other Resources to build executive dashboards that Google Analytics itself cannot produce.

What you'll learn

  • How to authenticate Retool with Google OAuth and configure the native Google Analytics Resource
  • How to write GA4 reporting queries with dimensions, metrics, and date range filters
  • How to build an executive analytics dashboard combining GA4 data with other data sources
  • How to use Chart components to visualize sessions over time and conversion funnels
  • How to use JavaScript transformers to reshape GA4's row/dimension response format
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate15 min read20 minutesAnalyticsLast updated April 2026RapidDev Engineering Team
TL;DR

Connect Retool to Google Analytics using the native Google Analytics Resource, authenticated via Google OAuth. Once configured, write GA4 reporting API queries to pull sessions, users, conversions, and custom dimensions into Retool Chart and Table components. You can combine web analytics data with revenue or support data from other Resources to build executive dashboards that Google Analytics itself cannot produce.

Quick facts about this guide
FactValue
ToolGoogle Analytics
CategoryAnalytics
MethodRetool Native Resource
DifficultyIntermediate
Time required20 minutes
Last updatedApril 2026

Why connect Retool to Google Analytics?

Google Analytics provides detailed web traffic data, but its built-in reporting UI has significant limitations for teams that need custom operational views. You cannot combine GA4 data with your CRM records, revenue database, or support ticket volume in Google's native interface. You cannot build interactive dashboards where a dropdown filters both GA4 metrics and Stripe revenue data simultaneously. Retool solves this by making GA4 just another data source you can query alongside any other Resource.

The most valuable Retool-Google Analytics use cases involve cross-source analysis: pulling GA4 traffic and conversion data alongside your PostgreSQL revenue database to show revenue per marketing channel, or combining GA4 session data with Zendesk ticket volume to identify correlation between traffic spikes and support load. You can also build internal analytics reporting panels that update automatically and are far simpler to share with stakeholders than GA4's complex custom report interface.

Retool's native connector supports GA4 properties (Google Analytics 4) using the GA4 Data API. If you still use Universal Analytics properties, the connector also supports the UA Reporting API. For GA4, queries specify a property ID, a date range, dimensions (breakdowns like device category, country, or page path), and metrics (values like sessions, users, conversions, or revenue). The response comes back as rows with dimension and metric values that you reshape with a transformer before binding to components.

Integration method

Retool Native Resource

Retool includes a native Google Analytics connector that authenticates via Google OAuth 2.0 and provides direct access to the GA4 Data API and the older Universal Analytics Reporting API. You configure the resource once in the Resources tab, and all subsequent queries run through Retool's server-side proxy against your Google Analytics properties. The connector supports dimensions and metrics selection, date ranges, segment filters, and pagination, making it straightforward to pull structured analytics data into Retool tables and charts.

Prerequisites

  • A Google Analytics 4 property with at least one stream collecting data
  • A Google account with Viewer or higher access to the GA4 property you want to query
  • The GA4 property ID (found in GA4 → Admin → Property Settings → Property ID)
  • A Retool account with Resource creation permissions
  • Basic familiarity with GA4 dimensions and metrics naming conventions

Step-by-step guide

1

Add the Google Analytics Resource in Retool

Navigate to the Resources tab in Retool's left sidebar and click Add Resource. In the resource type picker, scroll to or search for Google Analytics. Click it to open the configuration panel. Retool offers two Google Analytics resource types: Google Analytics (for Universal Analytics / GA3, now deprecated) and Google Analytics 4 for GA4 properties. Select Google Analytics 4 for any property created after October 2020. Give the resource a descriptive name such as Google Analytics - Production. In the Authentication section, click the Connect Google Account button. Retool redirects you to Google's OAuth consent screen where you will see a list of requested permissions — Retool needs read access to Google Analytics Data API to query your GA4 properties. Sign in with a Google account that has at least Viewer access to the GA4 property. After authorizing, Google redirects back to Retool and the resource configuration shows your authenticated Google account. You can optionally set a Default Property ID if you primarily query one GA4 property — enter the property ID in the format 123456789 (the numeric ID from GA4 Admin settings, not the measurement ID starting with G-). Click Save and confirm the resource shows a Connected status.

Pro tip: If multiple team members will use this Retool app, consider enabling Share OAuth 2.0 credentials between users in the resource settings — this prevents each user from having to individually authenticate with Google when they open the app.

Expected result: The Google Analytics 4 resource appears in your Resources list with a Connected status and your Google account email displayed.

2

Write a GA4 query for core traffic metrics

Open or create a Retool app and click + to create a new query in the Code panel. Select your Google Analytics 4 resource. The query editor shows GA4-specific fields: Property ID, Date ranges, Dimensions, and Metrics. In the Property ID field, enter your GA4 property ID (e.g., 123456789). Set the Date range to a relative range — select Last 30 days from the preset options, or set a custom date range using Retool's date picker components by referencing {{ dateRangePicker.startDate }} and {{ dateRangePicker.endDate }}. In the Dimensions section, click Add dimension and add date to get a day-by-day breakdown. In the Metrics section, add the metrics you want to track: sessions, activeUsers, newUsers, bounceRate, and conversions are the most common starting points. Click Run to execute the query. GA4 returns a rows array where each row has a dimensionValues array and a metricValues array — the values are positional, matching the order of dimensions and metrics you specified. This nested structure needs to be flattened with a transformer before you can bind it to a Table or Chart component meaningfully.

ga4_transformer.js
1// GA4 query transformer — flattens dimensionValues/metricValues into named objects
2// Paste into Advanced → Transform results
3const rows = data.rows || [];
4const dimensionHeaders = data.dimensionHeaders?.map(h => h.name) || [];
5const metricHeaders = data.metricHeaders?.map(h => h.name) || [];
6
7return rows.map(row => {
8 const obj = {};
9 // Map dimension values
10 (row.dimensionValues || []).forEach((val, i) => {
11 obj[dimensionHeaders[i] || `dim_${i}`] = val.value;
12 });
13 // Map metric values
14 (row.metricValues || []).forEach((val, i) => {
15 const key = metricHeaders[i] || `metric_${i}`;
16 // Convert numeric metric strings to numbers
17 obj[key] = isNaN(val.value) ? val.value : parseFloat(val.value);
18 });
19 return obj;
20});

Pro tip: The bounceRate metric in GA4 returns a decimal between 0 and 1 (e.g., 0.4523). Multiply by 100 in your transformer to display it as a percentage.

Expected result: The query returns structured rows of analytics data. After applying the transformer, each row is a flat object with named keys like date, sessions, activeUsers, newUsers — ready to bind directly to Table and Chart components.

3

Build a sessions over time Chart

Drag a Chart component from the Component panel onto the canvas. In the Chart's Data source field, set it to {{ getTrafficMetrics.data }} where getTrafficMetrics is the name of your GA4 query. Switch to the Chart configuration panel on the right side. Set Chart type to Line chart. Set the X axis to the date dimension field. Set the Y axis to sessions. The chart should immediately render a line showing daily session counts. To improve readability, configure the date field formatting in the Chart settings — GA4 returns dates in YYYYMMDD format (e.g., 20240315) so you may want to add a date formatting step to your transformer using new Date(dateStr.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3')).toLocaleDateString(). Add a second Y-axis data series for newUsers to show new vs returning traffic on the same chart. To make the chart date-responsive, add a DateRangePicker component to the canvas above the chart. Reference the picker's values in the GA4 query's date range fields using {{ dateRangePicker.value[0] }} and {{ dateRangePicker.value[1] }}. Set the GA4 query to auto-run when triggered and configure it to re-run when the date picker value changes using the query's dependencies or a manual trigger from the date picker's onChange event handler.

ga4_transformer_enhanced.js
1// Enhanced transformer with date formatting and percentage conversion
2const rows = data.rows || [];
3const dimensionHeaders = data.dimensionHeaders?.map(h => h.name) || [];
4const metricHeaders = data.metricHeaders?.map(h => h.name) || [];
5
6return rows.map(row => {
7 const obj = {};
8 (row.dimensionValues || []).forEach((val, i) => {
9 const key = dimensionHeaders[i] || `dim_${i}`;
10 if (key === 'date' && val.value && val.value.length === 8) {
11 // Convert YYYYMMDD to readable date
12 const d = val.value;
13 obj[key] = `${d.slice(0,4)}-${d.slice(4,6)}-${d.slice(6,8)}`;
14 } else {
15 obj[key] = val.value;
16 }
17 });
18 (row.metricValues || []).forEach((val, i) => {
19 const key = metricHeaders[i] || `metric_${i}`;
20 const num = parseFloat(val.value);
21 // Convert bounceRate from decimal to percentage
22 obj[key] = key === 'bounceRate' ? (num * 100).toFixed(1) + '%' : num;
23 });
24 return obj;
25});

Pro tip: For a cleaner executive dashboard, add Stat components above the chart showing totals for the selected period. Create a separate GA4 query with no date dimension (just metrics) to get period totals.

Expected result: A line chart showing daily sessions over the selected date range renders on the canvas, updating automatically when the date range picker is changed.

4

Add a traffic source breakdown table

Create a second GA4 query for channel breakdown. Use the same resource but change the Dimensions to sessionDefaultChannelGroup (GA4's channel grouping: Organic Search, Direct, Paid Search, etc.) and sessionSource for the specific traffic source. Set Metrics to sessions, activeUsers, and conversions. Remove the date dimension so this query returns aggregated totals per channel for the selected period rather than day-by-day data. Apply the same flattening transformer. Drag a Table component onto the canvas below the chart and bind it to {{ getChannelBreakdown.data }}. Configure column formatting: add a Number format to the sessions column, make the conversions column bold using conditional styling, and add a percentage column calculated as {{ currentRow.conversions / currentRow.sessions * 100 }} to show the conversion rate per channel. Sort the table by sessions descending by default. Add a Text component above the table as a heading: Traffic by Channel. To create the cross-source ROI analysis, add a third query targeting a PostgreSQL or other database Resource that contains revenue data attributed by channel. In a JavaScript query, merge the two datasets using the channel name as the join key and calculate revenue per session for each channel.

channel_join.js
1// JavaScript query to join GA4 channel data with revenue database
2// Assumes getChannelBreakdown.data and getRevenueByChannel.data are both available
3const gaData = getChannelBreakdown.data || [];
4const revenueData = getRevenueByChannel.data || [];
5
6// Build a lookup map from the revenue data
7const revenueMap = {};
8revenueData.forEach(row => {
9 revenueMap[row.channel?.toLowerCase()] = row.revenue || 0;
10});
11
12// Join datasets
13return gaData.map(row => {
14 const channel = (row.sessionDefaultChannelGroup || '').toLowerCase();
15 const revenue = revenueMap[channel] || 0;
16 const convRate = row.sessions > 0
17 ? ((row.conversions / row.sessions) * 100).toFixed(2)
18 : '0.00';
19 return {
20 channel: row.sessionDefaultChannelGroup,
21 sessions: row.sessions,
22 conversions: row.conversions,
23 conversion_rate: convRate + '%',
24 revenue: revenue > 0 ? `$${revenue.toLocaleString()}` : '$0',
25 revenue_per_session: row.sessions > 0
26 ? `$${(revenue / row.sessions).toFixed(2)}`
27 : '$0'
28 };
29});

Pro tip: GA4's sessionDefaultChannelGroup values are case-sensitive and use specific names like 'Organic Search' and 'Paid Search'. Match them exactly when joining to external data sources.

Expected result: A channel breakdown table shows sessions, conversions, conversion rate, and (if a revenue database is connected) revenue and revenue per session per channel, giving a complete picture of marketing performance.

5

Configure dashboard controls and sharing

Finalize the executive dashboard by adding interactive controls and configuring access. Add a Select component at the top of the dashboard with options for the GA4 property ID — this allows the same dashboard to serve multiple websites by switching the property. Reference the Select's value in both GA4 queries: {{ propertySelector.value }}. Add Stat components in a row at the top of the dashboard showing period totals for sessions, users, bounce rate, and conversions — use a separate aggregate GA4 query with no dimensions for these totals. Add a Refresh button with an onClick event that triggers all queries simultaneously. Configure query auto-run behavior: set both GA4 queries to re-run when the date range picker or property selector changes by adding those as query dependencies. In Retool's app settings, configure who can access this dashboard — share it with specific groups using Retool's permission system, or generate a public share link for stakeholders who do not have Retool accounts. If you want to embed the dashboard in an internal portal or Notion page, use Retool's embed URL option from the app's Share settings. For teams that need Google Analytics data in scheduled reports or Slack digests, use Retool Workflows with a scheduled trigger to query GA4 daily and send formatted summaries.

Pro tip: GA4's Data API has quotas: 200,000 tokens per project per day and 20,000 tokens per hour. Enable Retool's query caching (15-60 minutes) on dashboard queries to stay well within these limits.

Expected result: A complete executive analytics dashboard displays with date range controls, property switching, a sessions trend chart, a channel breakdown table, and summary stat components — all updating in sync from a single date picker.

Common use cases

Executive website performance dashboard

Build a Retool dashboard that shows weekly and monthly GA4 metrics — sessions, new users, bounce rate, and goal completions — in a combination of Chart and Stat components. Date range pickers let stakeholders slice the data dynamically. A second panel pulls the same metrics broken down by traffic source, displayed in a Table with conditional formatting to highlight channels that are trending up or down.

Retool Prompt

Build a Retool dashboard showing GA4 metrics for the last 30 days including total sessions, new users, bounce rate, and conversions in Stat components at the top. Below that, show a line Chart of daily sessions over time and a Table breaking down sessions and conversions by traffic source/medium.

Copy this prompt to try it in Retool

Marketing channel ROI dashboard

Combine Google Analytics traffic and conversion data with PostgreSQL revenue records to calculate actual ROI per marketing channel. GA4 provides sessions and conversions by source/medium, while a connected database provides average order value and revenue attributed to each channel. The Retool dashboard joins these datasets in a JavaScript transformer and displays ROI metrics that neither system can produce independently.

Retool Prompt

Build a Retool app that queries Google Analytics for sessions and conversions by source/medium for the last 90 days, queries a PostgreSQL database for revenue by acquisition channel, and joins them in a JavaScript transformer to display sessions, conversions, revenue, and calculated ROI per channel in a single Table.

Copy this prompt to try it in Retool

Content performance audit tool

Create a Retool panel for content teams that shows page-level GA4 metrics: page views, average session duration, bounce rate, and conversion rate for each URL. Filter by date range and page path prefix to focus on specific content sections. A bulk export button lets content managers export the filtered data for their editorial planning process.

Retool Prompt

Build a Retool content analytics tool that queries GA4 for the top 100 pages by pageviews in a given date range, showing page path, pageviews, average engagement time, and conversions in a Table. Include a text input to filter by page path prefix and a date range picker.

Copy this prompt to try it in Retool

Troubleshooting

Query returns 'User does not have sufficient permissions' error

Cause: The Google account authenticated with the Retool Resource does not have at least Viewer access to the GA4 property ID specified in the query.

Solution: In Google Analytics, go to Admin → Property Access Management and confirm the authenticated Google account has Viewer, Editor, or Administrator role on the property. Alternatively, if you shared OAuth credentials, the account that initially authenticated may have access while another user does not — verify the shared credentials have access to all required properties.

Chart renders but shows no data points, even though the query returns rows

Cause: GA4 returns date values in YYYYMMDD format (e.g., 20240315). Retool's Chart component may not parse this as a valid date for the time-series X axis without reformatting.

Solution: Add date reformatting to your transformer: convert 20240315 to 2024-03-15 using the string slice pattern. The Chart component recognizes ISO date format strings for time-series axes. See the enhanced transformer example in Step 3.

typescript
1// In transformer, convert GA4 date format
2const dateStr = row.dimensionValues[0].value; // e.g. '20240315'
3const formatted = `${dateStr.slice(0,4)}-${dateStr.slice(4,6)}-${dateStr.slice(6,8)}`;

Query returns a quota exceeded error after running several times

Cause: The GA4 Data API enforces daily and hourly token quotas. Dashboards with many queries or high refresh frequency can exhaust quotas, especially during development testing.

Solution: Enable Retool query caching in the query's Advanced tab with a duration of 15-60 minutes for dashboard queries. Avoid setting queries to run on every component change — use explicit triggers instead. During development, use a lower-traffic GA4 property or a test property to preserve production quotas.

Best practices

  • Use GA4 property IDs (numeric, e.g., 123456789) not measurement IDs (G-XXXXXXXX) in Retool query configuration — the Data API requires the numeric property ID.
  • Apply the dimensionValues/metricValues flattening transformer to every GA4 query before binding to components — raw GA4 responses use positional arrays that are difficult to work with directly.
  • Enable query caching (15-60 minutes) on dashboard queries to stay within GA4 Data API quotas and keep the dashboard responsive when multiple users are viewing simultaneously.
  • Use relative date ranges (last 30 days, last 7 days) referenced from DateRangePicker components rather than hardcoded dates — this keeps dashboards useful without manual updates.
  • Create separate aggregate queries (no date dimension) for summary stat components and breakdown queries (with dimensions) for charts and tables, rather than trying to derive totals from a breakdown query in JavaScript.
  • Store the GA4 property ID in a Retool configuration variable if you deploy the same dashboard template across multiple teams or clients — this makes customization faster than finding and replacing property IDs in every query.
  • For dashboards shared with executives who do not have Retool accounts, use Retool's public share link or embed URL rather than granting full Retool access — they can view and interact with filters without a Retool login.

Alternatives

Frequently asked questions

Does Retool support Google Analytics 4 (GA4) or only Universal Analytics?

Retool supports both GA4 and Universal Analytics through its native Google Analytics Resource. When creating the resource, select Google Analytics 4 for properties created after 2020. Universal Analytics was officially sunset by Google in July 2024, so most current integrations should use GA4. The query interface differs between the two — GA4 uses the Data API with dimensions and metrics, while UA used the older Reporting API v4.

Can I query multiple GA4 properties from a single Retool app?

Yes. Create one Google Analytics Resource in Retool and configure queries with different property IDs. You can make the property ID dynamic using a Select component: {{ propertySelector.value }}. This allows a single dashboard to display data for multiple websites by switching the property selector. Alternatively, create multiple named Resources if you want hard-coded separation between properties.

Is there a way to combine Google Analytics data with my database in Retool?

Yes, this is one of the strongest use cases for the integration. Run GA4 and database queries in parallel, then use a JavaScript query to join the datasets using a common key (typically channel name or page URL). The channel ROI example in this guide demonstrates this pattern. Retool's JavaScript queries can reference any other query's .data property directly.

Can Retool write data back to Google Analytics?

The native Google Analytics Resource in Retool is read-only — it uses the GA4 Data API for reporting only. To send events to Google Analytics from Retool, you would use the GA4 Measurement Protocol via a REST API Resource to POST events directly to the /mp/collect endpoint. However, sending events from an internal tool to your analytics property is uncommon and can skew your traffic data.

What is the difference between using Retool and Google Data Studio for GA4 reporting?

Google Data Studio (Looker Studio) is purpose-built for GA4 visualization and requires no setup for basic reports. Retool's advantage is combining GA4 data with any other data source — databases, CRMs, payment processors — in a single dashboard, and building interactive operational tools (not just reports) where users can take actions based on the analytics data.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Integrations are where projects stall

We wire Retool integrations like this one every week — auth, webhooks, edge cases included. Fixed-price builds from $13K, delivered in 6–10 weeks.

Talk to an integration engineer

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.