Connecting Google Analytics 4 to your Configured Commerce website includes the following steps. These steps are described in more detail below:
- Create or sign in into your Google Analytics account.
- Create a new Google Analytics 4 web property for your Optimizely site and environment. You will need to do this once for Sandbox and, after completing Sandbox testing, again for Production.
- Create a new web data stream for the GA4 web property.
- Add custom dimensions to the web data stream.
- Save or record the Measurement ID for your new GA4 web property.
Create or sign in to your Google Analytics account
- If needed, create a new Google Analytics account.
- If you already have a Google Analytics account, then sign in to Google Analytics.
Create a new Google Analytics 4 Web Property for your site and environment
- Click Admin on the left navigation bar.
- Select the main website account under Account.
- Verify that your website has not already been set up by reviewing the list of Properties available in the dropdown list under Property.
- Select Create Property.
- Enter a name for your site in the Property name field. Optimizely recommends that you indicate the environment to which the property relates. For example, “My Website Name – Sandbox.”
- Update the Reporting time zone and Currency fields, as necessary.
- Click Next.
- Fill out any information you choose in the About your business section.
- Click Create. The page should automatically update to the Data Streams page with the headline Start collecting data.
Create a new web data stream
- Click Web to create a new Web data stream. On the Set up data stream page, enter your Website URL and create a Stream name.
- Click the stream Settings button to the bottom right. On the Enhanced measurement settings page, disable everything except Page views. Click Save.
- Click Create stream. Your GA4 stream has been created. You will see the Installation instructions screen, but installation is not required until Google Tag Manager setup is complete.
- Close the Installation instructions page.
- Take note of the Stream Name, Stream URL, Stream ID, and Measurement ID on the Web Stream Details page. The Measurement ID will be required for setting up Google’s Tag Manager and the go-live checklist. Close the Web Stream Details page.
- Acknowledge the user data collection agreement by returning to the Admin > Property menu. Under Data Settings, select Data Collection. Open the bottom section entitled User Data Collection Acknowledgement, and click I acknowledge.
Create custom dimensions
- Return to the Admin > Property menu. Click on Custom definitions, then Create custom dimensions.
- Create each of the below dimensions one at a time and click Save each time.
Save or record the Measurement ID for your new GA4 web property
You will need to reference your Measurement ID in the next two steps of implementation. To find the Measurement ID at any time in the future, follow these steps:
- Log into Google Analytics.
- Click Admin.
- Select the Account and Property associated with your GA4 instance.
- Go to Property > Data Streams.
- Select the Data Stream that is associated with your GA4 implementation. The Measurement ID will appear on the Web stream details page.
You have completed a basic setup for Google Analytics 4. Once you have verified Google Analytics data in Sandbox, you will need to repeat the process for Production. The setup for production will be identical to Sandbox but will have a property.