---
title: Set up Google Analytics for your website
slug: configured-commerce/analytics/set-up-google-analytics-for-your-website
docTags: 
createdAt: 2026-08-05T19:31:37.379Z
---

You must complete four steps to set up Google Analytics 4 (GA4):

- Log in to your Google Analytics account
- Create a new property (per site, per environment)
- Create a web data stream for the property
- Add custom definitions to the property

Implementation of Google Analytics requires a testing process. Optimizely recommends that you implement Google Analytics on your Sandbox site first and verify accurate tracking of user events before recreating the tracking on your Production site. You must complete the following steps twice: once for Sandbox and once for Production. This additional testing step is important because once GA data has been captured and added to your Google Analytics database, it cannot be removed.

## Create or sign in to your Google Analytics account

Create a [new Google Analytics account](https://support.google.com/analytics/answer/10089681) if you do not already have one, or [sign in to Google Analytics](https://analytics.google.com).

## Create a Google Analytics 4 Web Property for your site and environment

1. Click on **Admin** in the navigation bar. The Admin page has two columns: Account and Property.
2. Open the dropdown list under **Account** and select the main account for your website.
3. Review the list of **Properties** to see if GA4 has been set up for your site. If not, select **Create Property**.
4. Enter a name for your site in the **Property name** field. Optimizely recommends that you indicate which environment the property relates to as well. For example, “My Website Name – GA4 Sandbox.”
5. Update the **Reporting time zone** and **Currency** fields, as necessary.
6. Click **Next**.
7. Fill in the fields requested by Google for the **Describe Your Business** page.
8. Select the objectives that you are most interested in on the **Choose Your Business Objectives** page. Optimizely recommends selecting at least **Drive online sales** and **Examine user behavior**.
9. Click **Create**. The page should automatically update to the Data Streams page with the headline **Start collecting data**.

## Create a web data stream

1. Click **Web** to create a new Web data stream.
2. Enter your **Website URL** and create a **Stream name**, such as "GA4 Web Property – Sandbox".
3. Click the **Settings** wheel icon to the right of the page.
4. Disable everything except **Page views** under **Enhanced measurement**. Click **Save**.
5. Click **Create stream**. You will see the **Installation instructions** screen, but installation is not required until Google Tag Manager (step #2) is complete.
6. Close the Installation Instructions page. On the **Web stream details** page, note the Stream Name, Stream URL, Stream ID, and Measurement ID. You need the Measurement ID to set up Google’s Tag Manager and for the Go Live Checklist (Steps #2 and #3). Close the Web Stream Details page.
7. Click **Next** to complete the web data stream set-up.
8. Click **Continue to Home**. If a pop-up screen appears entitled **Migrating from Universal Analytics**, Optimizely recommends selecting No for the most simple implementation of GA4.
9. Return to **Admin** > **Property**. Select the web property that you just created in the property pull down list.
10. Select **Data Collection** under **Data Settings**. Open the bottom section entitled **User** **Data Collection Acknowledgement**, and click **I acknowledge**.

## Create custom dimensions

**Customers who already have GA4 set up**

1. [Sign in to you Google Analytics account](https://analytics.google.com).
2. Go to **Admin** > **Property**.
3. Click on **Custom definitions** > **Create custom dimensions**.
4. Create each of the below dimensions one at a time and click **Save** each time.

| No. | Dimension name | Scope | Description | Event parameter/ User property |
| --- | -------------- | ----- | ----------- | ------------------------------ |
| 1   | item\_ID       | Item  | item\_ID    | sku                            |
| 2   | item\_name     | Item  | item\_name  | name                           |

**Customer who do not have GA4 set up yet**

1. Return to the **Admin** > **Property** menu.
2. Click on **Custom definitions** > **Create custom dimensions**.
3. Create each of the below dimensions one at a time and click **Save** each time.

| No. | Dimension name            | Scope | Description               | Event parameter/User property |
| --- | ------------------------- | ----- | ------------------------- | ----------------------------- |
| 1   | Authentication\_State     | Event | Authentication\_State     | Authentication\_State         |
| 2   | correctedQuery            | Event | correctedQuery            | correctedQuery                |
| 3   | endingUrl                 | Event | endingUrl                 | endingUrl                     |
| 4   | ga\_session\_id           | Event | ga\_session\_id           | analytics\_session\_id        |
| 5   | numSearchResults          | Event | numSearchResults          | numSearchResults              |
| 6   | Page\_Path                | Event | Page\_Path                | Page\_Path                    |
| 7   | Page\_Path\_1             | Event | Page\_Path\_1             | Page\_Path\_1                 |
| 8   | product\_numSearchResults | Event | product\_numSearchResults | product\_numSearchResults     |
| 9   | searchQuery               | Event | searchQuery               | searchQuery                   |
| 10  | User\_ID                  | Event | User\_ID                  | App\_User\_ID                 |
| 11  | item\_ID                  | Item  | item\_ID                  | sku                           |
| 12  | item\_name                | Item  | item\_name                | name                          |

## Save or record the Measurement ID for your GA4 web property

You must reference your Measurement ID during implementation. You can find the Measurement ID by following these steps:

1. [Log in to Google Analytics](https://analytics.google.com/).
2. Click **Admin**.
3. Select the **Account** and **Property** associated with your GA4 instance.

   ::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/EunN65__kbcr9lWPdtAAI-20260720-144544.png" size="100" isUploading="false" showCaption="false"}
4. Select **Data Streams** and select the Data Stream associated with your GA4 implementation.
5. Notice the **Measurement ID** on the **Web stream details** page.

   ::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/2SBWhsjvCMHePwzK7SjAg-20260720-144545.png" size="100" isUploading="false" showCaption="false"}

You have now completed a basic set-up for Google Analytics 4. Once you have verified the Google Analytics data in Sandbox, you need to repeat the steps for Production. The setup for production is identical to Sandbox but with a different web property.
