Skip to main content
RapidDev - Software Development Agency
bubble-tutorial

How to set up Google Analytics in Bubble

Setting up Google Analytics 4 in Bubble requires adding the measurement ID to your app's header, configuring custom event tracking via Run JavaScript actions in workflows, and verifying data appears in GA4 reports. This tutorial covers the complete GA4 implementation from setup through custom event tracking and data verification.

What you'll learn

  • How to add the GA4 measurement ID to your Bubble app
  • How to track custom events using Run JavaScript workflow actions
  • How to verify analytics data appears in GA4 reports
  • How to set up conversion tracking for key user actions
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read15-20 minAll Bubble plansMarch 2026RapidDev Engineering Team
TL;DR

Setting up Google Analytics 4 in Bubble requires adding the measurement ID to your app's header, configuring custom event tracking via Run JavaScript actions in workflows, and verifying data appears in GA4 reports. This tutorial covers the complete GA4 implementation from setup through custom event tracking and data verification.

Overview: Setting Up Google Analytics in Bubble

Google Analytics 4 (GA4) provides essential insights into user behavior in your Bubble app. This tutorial walks through adding the GA4 tracking code, configuring custom event tracking for important user actions, and verifying that data flows correctly into your GA4 dashboard.

Prerequisites

  • A Google Analytics account with a GA4 property created
  • Your GA4 Measurement ID (format: G-XXXXXXXXXX)
  • A Bubble app you want to track
  • Basic understanding of Bubble's Settings tab

Step-by-step guide

1

Add the GA4 tracking code to your Bubble app

Go to your Bubble editor, click Settings in the left sidebar, then click the SEO / metatags tab. Find the 'Script/meta tags in header' section. Paste the GA4 tracking script provided by Google Analytics. It looks like: a script tag loading gtag.js from googletagmanager.com with your Measurement ID, followed by a script block that initializes the gtag with your ID. This code loads on every page of your app, tracking all page views automatically.

GA4 tracking script
1<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
2<script>
3 window.dataLayer = window.dataLayer || [];
4 function gtag(){dataLayer.push(arguments);}
5 gtag('js', new Date());
6 gtag('config', 'G-XXXXXXXXXX');
7</script>

Expected result: GA4 tracking code is installed in your app's header, loading on every page.

2

Verify the tracking code is working

Preview your Bubble app in a browser. Open Google Analytics 4 and go to Reports → Realtime. You should see at least one active user (yourself). If no data appears after a few minutes, check: is the Measurement ID correct, is the script in the Header section (not the Body), and are there any browser extensions blocking tracking (like ad blockers). You can also use the Google Tag Assistant Chrome extension to verify the tag is firing correctly. Wait up to 24 hours for data to appear in standard (non-realtime) GA4 reports.

Pro tip: Use GA4's DebugView (Configure → DebugView) with the Google Analytics Debugger Chrome extension for detailed event inspection.

Expected result: GA4 Realtime report shows active users and page views from your Bubble app.

3

Track custom events with Run JavaScript actions

In your Bubble workflows, you can fire custom GA4 events using the Run JavaScript action (found under Element Actions or via a JavaScript plugin). For example, when a user completes a signup, add a Run JavaScript action: gtag('event', 'sign_up', { method: 'email' }). For a purchase: gtag('event', 'purchase', { value: [order total], currency: 'USD', transaction_id: '[order id]' }). Add these JavaScript actions to the appropriate workflow triggers (button clicks, page loads, form submissions).

GA4 custom events
1// Sign up event
2gtag('event', 'sign_up', {
3 method: 'email'
4});
5
6// Purchase event
7gtag('event', 'purchase', {
8 transaction_id: 'T12345',
9 value: 49.99,
10 currency: 'USD'
11});
12
13// Custom event
14gtag('event', 'feature_used', {
15 feature_name: 'dashboard_export'
16});

Expected result: Custom events fire in GA4 when users perform specific actions in your Bubble app.

4

Set up conversion tracking for key actions

In GA4, go to Configure → Events. Find the custom events you created (sign_up, purchase, etc.). Click the toggle to mark them as conversions. Now these events appear in the Conversions report with counts and conversion rates. For e-commerce tracking, use GA4's recommended events (purchase, add_to_cart, begin_checkout) with the standard parameters so GA4 can build automatic e-commerce reports. Review conversions daily during the first week to ensure data is flowing correctly.

Expected result: Key user actions are tracked as conversions in GA4 with visible reports.

5

Track page views for single-page-app navigation

Bubble apps that use group-based navigation (showing/hiding groups instead of navigating to new pages) do not automatically trigger GA4 page views for virtual page changes. To fix this, add a Run JavaScript action in workflows that change the visible 'page': gtag('event', 'page_view', { page_title: 'Dashboard', page_location: window.location.href + '/dashboard' }). This sends a page_view event with a virtual URL so GA4 records the navigation even though the actual URL did not change.

Expected result: GA4 tracks virtual page views for single-page-app style navigation in your Bubble app.

Complete working example

GA4 tracking script
1{
2 "header_script": "<script async src='https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX'></script>\n<script>\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', 'G-XXXXXXXXXX');\n</script>",
3 "custom_events": {
4 "sign_up": "gtag('event', 'sign_up', { method: 'email' })",
5 "purchase": "gtag('event', 'purchase', { transaction_id: '[id]', value: [amount], currency: 'USD' })",
6 "page_view_virtual": "gtag('event', 'page_view', { page_title: '[title]', page_location: window.location.href + '/[path]' })",
7 "feature_used": "gtag('event', 'feature_used', { feature_name: '[name]' })",
8 "search": "gtag('event', 'search', { search_term: '[query]' })"
9 },
10 "placement": "Settings → SEO/metatags → Script/meta tags in header",
11 "verification": "GA4 → Reports → Realtime → check for active user",
12 "conversions": "GA4 → Configure → Events → toggle conversion for key events"
13}

Common mistakes when setting up Google Analytics in Bubble

Why it's a problem: Placing the tracking script in the page body instead of the header

How to avoid: Always paste the GA4 script in Settings → SEO/metatags → Script/meta tags in header

Why it's a problem: Not tracking virtual page views in SPA-style navigation

How to avoid: Add gtag('event', 'page_view', {...}) Run JavaScript actions in workflows that change visible sections

Why it's a problem: Using dynamic Bubble expressions directly in Run JavaScript

How to avoid: Set dynamic values in a custom state or hidden input first, then reference them in JavaScript using document.getElementById or a Bubble-to-JS bridge

Best practices

  • Place the GA4 script in the header section of Settings for reliable loading
  • Verify tracking using GA4 Realtime reports before relying on the data
  • Use GA4's recommended event names (sign_up, purchase, search) for automatic reporting
  • Mark key events as conversions in GA4 Configure → Events
  • Track virtual page views for SPA-style navigation patterns
  • Test custom events with GA4 DebugView and the Google Analytics Debugger extension

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I need to set up Google Analytics 4 in my Bubble app. I want to track page views, sign-ups, and purchases as conversions. Can you help me with the tracking code and custom event configuration?

Bubble Prompt

Help me add Google Analytics 4 tracking to my app. I need the header script installed, custom events for sign-up and purchase actions, and virtual page view tracking for my group-based navigation.

Frequently asked questions

Where do I find my GA4 Measurement ID?

In Google Analytics, go to Admin → Data Streams → select your stream. The Measurement ID starts with G- and is displayed at the top of the stream details page.

Does GA4 work on Bubble's free plan?

Yes. You can add the GA4 tracking script on any Bubble plan. The script runs in the browser and does not consume Bubble workload units.

How long until data appears in GA4?

Realtime reports update within seconds. Standard reports can take 24-48 hours to populate with data.

Can I use Google Tag Manager instead of direct GA4?

Yes. Add the GTM container script in the header instead of the GA4 script. Then manage all your tags (GA4, Facebook Pixel, etc.) through Google Tag Manager.

Will GA4 slow down my Bubble app?

The impact is minimal. The gtag.js script loads asynchronously and does not block page rendering. For most apps, users will not notice any difference.

Can RapidDev help set up analytics for my Bubble app?

Yes. RapidDev can implement GA4, Google Tag Manager, custom event tracking, conversion funnels, and analytics dashboards for comprehensive insights into your Bubble app's user behavior.

RapidDev

Talk to an Expert

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

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

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.