> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withsurface.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics Tracking

> Track Surface Form events in Google Analytics using Google Tag Manager (GTM)

<Warning>
  Make sure to implement [Google Tag Manager
  (GTM)](/docs/events/google-tag-manager) first before setting up Google
  Analytics tracking.
</Warning>

## 1. Create a new data stream in Google Analytics

<Frame>
  <img src="https://mintcdn.com/surfacelabs/rGGCmoCGFxRQ_IvW/images/google-analytics/1.png?fit=max&auto=format&n=rGGCmoCGFxRQ_IvW&q=85&s=dda9892835a68428b3158fe6dfac45de" alt="Create Data Stream Step 1" width="1911" height="951" data-path="images/google-analytics/1.png" />
</Frame>

Navigate to your Google Analytics property and create a new data stream for your website.

**Steps:**

1. Go to **Admin** → **Data Collection and Modification** → **Data Streams**
2. Click **Add stream** → **Web**
3. Enter your website URL and stream name
4. Click **Create stream**

## 2. Get the Google Analytics Measurement ID

<Frame>
  <img src="https://mintcdn.com/surfacelabs/rGGCmoCGFxRQ_IvW/images/google-analytics/2.png?fit=max&auto=format&n=rGGCmoCGFxRQ_IvW&q=85&s=6295a955c3f73643a28ca5194fa8bc9a" alt="Create Data Stream Step 2" width="1911" height="951" data-path="images/google-analytics/2.png" />
</Frame>

Once your data stream is created, you'll need to copy the Measurement ID to use in GTM.

**Steps:**

1. In the data stream settings, click on your newly created data stream
2. Copy the **Measurement ID** (starts with G-XXXXXXXXXX)

## 3. Create Custom Events in Google Analytics

Before setting up triggers in GTM, you need to create custom events in Google Analytics.

**Steps:**

<Frame>
  <img src="https://mintcdn.com/surfacelabs/fh7I1ky4S5zFKU98/images/google-analytics/6.png?fit=max&auto=format&n=fh7I1ky4S5zFKU98&q=85&s=20bd85c66c59fccd16a56cf8e8692657" alt="Create Custom Event Step 1" width="3000" height="1702" data-path="images/google-analytics/6.png" />
</Frame>

1. Go to **Admin** → **Data Display** → **Events**
2. Click **Create event**
3. Name the event **SurfaceFormSubmitEvent** (this should match the event name you'll use in GTM)
4. Scroll down and click **View more options**

<Columns cols={2}>
  <Frame>
    <img src="https://mintcdn.com/surfacelabs/fh7I1ky4S5zFKU98/images/google-analytics/7.png?fit=max&auto=format&n=fh7I1ky4S5zFKU98&q=85&s=30bafefac6353320996b2c60f42d688b" alt="Create Custom Event Step 2" width="3000" height="1702" data-path="images/google-analytics/7.png" />
  </Frame>

  <Frame>
    <img src="https://mintcdn.com/surfacelabs/fh7I1ky4S5zFKU98/images/google-analytics/8.png?fit=max&auto=format&n=fh7I1ky4S5zFKU98&q=85&s=f809d6c17bc0ffa500edd8e0c26631ad" alt="Create Custom Event Step 3" width="1901" height="575" data-path="images/google-analytics/8.png" />
  </Frame>
</Columns>

5. Under **Matching conditions**, remove the `page_location` parameter
6. Click **Save**

## 4. Create Custom Event Triggers in GTM

<Columns cols={2}>
  <Frame>
    <img src="https://mintcdn.com/surfacelabs/Z1OPSxKTjQBidDgE/images/gtm/gtm_5.png?fit=max&auto=format&n=Z1OPSxKTjQBidDgE&q=85&s=1e1b3418eefbecd92ef723bdafe0e260" alt="Create Custom Event Trigger Step 1" width="3838" height="2396" data-path="images/gtm/gtm_5.png" />
  </Frame>

  <Frame>
    <img src="https://mintcdn.com/surfacelabs/Z1OPSxKTjQBidDgE/images/gtm/gtm_6.png?fit=max&auto=format&n=Z1OPSxKTjQBidDgE&q=85&s=dea718620c3024528d7987c7e6920b76" alt="Create Custom Event Trigger Step 2" width="3024" height="1714" data-path="images/gtm/gtm_6.png" />
  </Frame>
</Columns>

Set up trigger for the Surface Form events you want to track in Google Analytics.

**Steps:**

1. In GTM, go to **Triggers**
2. Click **New** → **Trigger Configuration**
3. Select **Custom Event**
4. Enter the event name as **SurfaceFormSubmitEvent**
5. Click **Save**

## 5. Create Google Analytics GA4 Event Tags

<Columns cols={2}>
  <Frame>
    <img src="https://mintcdn.com/surfacelabs/rGGCmoCGFxRQ_IvW/images/google-analytics/4.png?fit=max&auto=format&n=rGGCmoCGFxRQ_IvW&q=85&s=8a41dd0b25010e6d8f4dbea575912cc3" alt="Create Google Analytics GA4 Event Tags Step 1" width="1911" height="951" data-path="images/google-analytics/4.png" />
  </Frame>

  <Frame>
    <img src="https://mintcdn.com/surfacelabs/rGGCmoCGFxRQ_IvW/images/google-analytics/3.png?fit=max&auto=format&n=rGGCmoCGFxRQ_IvW&q=85&s=2c65882dc70538be6a090c8fde09058f" alt="Create Google Analytics GA4 Event Tags Step 2" width="1911" height="951" data-path="images/google-analytics/3.png" />
  </Frame>
</Columns>

Now create GA4 Event tags that will send the Surface Form events to Google Analytics.

**Steps:**

1. In GTM, go to **Tags**
2. Click **New** → **Tag Configuration**
3. Select **Google Analytics: GA4 Event**
4. Enter your **Measurement ID** (from Step 2)
5. Set the **Event Name**
6. Under **Triggering**, select the trigger you created in Step 4
7. Click **Save**

## 6. Submit and Publish Changes

<Frame>
  <img src="https://mintcdn.com/surfacelabs/Z1OPSxKTjQBidDgE/images/gtm/gtm_11.png?fit=max&auto=format&n=Z1OPSxKTjQBidDgE&q=85&s=e658b26561c5a4e943e6e4eb072baca9" alt="Submit Changes" width="2534" height="1434" data-path="images/gtm/gtm_11.png" />
</Frame>

1. Click **Submit** in GTM
2. Add a version name and description
3. Click **Publish**

## Testing using Google Tag Assistant

<Frame>
  <img src="https://mintcdn.com/surfacelabs/rGGCmoCGFxRQ_IvW/images/google-analytics/5.png?fit=max&auto=format&n=rGGCmoCGFxRQ_IvW&q=85&s=cd1aaf82772724374035f7a3baa568e1" alt="Google Tag Assistant Step 1" width="1911" height="951" data-path="images/google-analytics/5.png" />
</Frame>

1. Install the [Google Tag Assistant extension](https://tagassistant.google.com/) in your browser
2. Go to [tagassistant.google.com](https://tagassistant.google.com/)
3. Click **Add domain** and enter your website URL > Click **Connect** - this will open your website in a new tab
4. Fill out and submit a Surface Form to see the events being tracked
