Help center

Google Analytics 4 (GA4)

Google Analytics 4 integration allows you to track form submissions and views in your GA4 property using server-side tracking. This approach is GDPR compliant as it doesn't require cookies or client-side JavaScript.

Overview

Axiforms sends events to GA4 using the Measurement Protocol API, which enables:

  • Server-side tracking: No cookies required, GDPR compliant
  • Form view tracking: Track when forms are viewed
  • Form submission tracking: Track when forms are submitted
  • Reliable data: Events are sent directly from the server, ensuring delivery even if users have ad blockers

Events Tracked

form_viewed

Triggered when a form page is loaded (server-side).

Event Parameters:

  • form_id: Project ID
  • form_name: Form name
  • form_slug: Form slug (if available)

form_submitted

Triggered when a form is submitted.

Event Parameters:

  • form_id: Project ID
  • form_name: Form name
  • form_slug: Form slug (if available)
  • response_id: Unique identifier for the submission

Setting Up GA4 Integration

Step 1: Get Your GA4 Credentials

  1. Go to your Google Analytics 4 Admin
  2. Select your property (or create a new one)
  3. Go to AdminData Streams
  4. Click on your web data stream
  5. Note your Measurement ID (format: G-XXXXXXXXXX)

Step 2: Create an API Secret

  1. In the same data stream settings, scroll to Measurement Protocol API secrets
  2. Click Create
  3. Give it a nickname (e.g., "Axiforms Server")
  4. Click Create and copy the API Secret (you won't be able to see it again)

Step 3: Configure Integration in Axiforms

  1. Navigate to your form's SettingsIntegrations
  2. Click on Google Analytics 4
  3. Enter your Measurement ID (e.g., G-XXXXXXXXXX)
  4. Enter your API Secret
  5. Enable the integration
  6. Click Create Integration

Configuration

Measurement ID

Your GA4 Measurement ID follows the format G-XXXXXXXXXX. You can find it in:

  • GA4 Admin → Data Streams → Your stream → Measurement ID

API Secret

The API Secret is used to authenticate requests to the Measurement Protocol. It's different from your Measurement ID and should be kept secure.

Viewing Events in GA4

Once configured, events will appear in your GA4 dashboard:

  1. Go to ReportsRealtime to see live events
  2. Go to ReportsEngagementEvents to see historical data
  3. Use Explore to create custom reports

Example Reports

  • Form Views by Form: Track which forms are most viewed
  • Submission Rate: Calculate submissions / views
  • Submission Funnel: Track user journey from view to submission

GDPR Compliance

This integration is GDPR compliant because:

  • No cookies: Events are sent server-side, no tracking cookies required
  • No client-side JavaScript: Works even with strict privacy settings
  • Server-side only: Data is sent directly from Axiforms servers to GA4
  • User consent: You can implement your own consent mechanism for GDPR compliance

Limitations

  • Client ID: GA4 requires a client_id for event tracking. Axiforms generates a deterministic client ID based on the form and response, which may not track individual users across sessions.
  • Session tracking: Advanced session tracking features may not work perfectly without client-side JavaScript.
  • Real-time attribution: Some GA4 features that require client-side tracking won't be available.

Best Practices

  1. Use consistent naming: Keep form names consistent to ensure proper grouping in GA4
  2. Monitor event volume: Check your GA4 dashboard regularly to ensure events are being tracked
  3. Combine with client-side tracking: For richer analytics, consider adding GA4 client-side tracking alongside this integration
  4. Set up custom dimensions: Use GA4 custom dimensions to track additional metadata if needed

Troubleshooting

Events not appearing in GA4

  • Verify your Measurement ID format (should be G-XXXXXXXXXX)
  • Check that your API Secret is correct
  • Ensure the integration is enabled
  • Check GA4 Realtime reports (events may take a few minutes to appear)
  • Verify that you have permission to view events in your GA4 property

Invalid API Secret error

  • Ensure you copied the API Secret correctly (no extra spaces)
  • API Secrets are sensitive - they cannot be retrieved after creation
  • Create a new API Secret if you've lost yours

Testing Events

  1. Submit a test form to trigger a form_submitted event
  2. View the form page to trigger a form_viewed event
  3. Check GA4 Realtime reports within 30 seconds
  4. Look for events with names form_viewed and form_submitted

API Reference

Measurement Protocol

Axiforms uses the GA4 Measurement Protocol to send events:

POST https://www.google-analytics.com/mp/collect?measurement_id={MEASUREMENT_ID}&api_secret={API_SECRET}

The payload includes:

  • client_id: Generated client identifier
  • events: Array of events (form_viewed or form_submitted)

For more information, see the GA4 Measurement Protocol documentation.