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. The following steps will need to be completed twice: once for Sandbox and once for Production.
Create or sign-into your Google Analytics account
Sign in to Analytics at https://analytics.google.com.
Create a new Google Analytics 4 Web property for your site and environment
- Click on Admin in the navigation bar. The Admin page has two columns: Account and Property. Open the dropdown list under Account and select the main account for your website.
- Review the list of Properties to see if GA4 has been set up for your site.
- Select Create Property.
- 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.”
- 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.
- Enter your Website URL and create a Stream name, such as "GA4 Web Property – Sandbox".
- Click Settings.
- Disable everything except Page views under Enhanced measurement. Click Save.
- Click Create stream. You will see the Installation instructions screen, but installation is not required until Google Tag Manager (step #2) is complete.
- 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.
- Acknowledge the user data collection agreement.
- Return to Admin > Property.
- Select Data Collection under Data Settings. Open the bottom section entitled User Data Collection Acknowledgement, and click I acknowledge.
Create custom dimensions
- Return to Admin > Property. Click on Custom definitions > 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 in to Google Analytics.
- Click Admin.
- Select the Account and Property associated with your GA4 instance.
- Select Data Streams and select the Data Stream associated with your GA4 implementation.
- Notice the Measurement ID on the Web stream details page.
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 will be identical to Sandbox but will have a property.