EPiServer.GoogleAnalytics now support Google Analytics GA4
As you know Google Analytics 4 is replacing Universal Analytics. On July 1, 2023, your Universal Analytics properties will stop collecting data. Only GA4 properties will collect data after July 1.
We have just released the latest version of the EPiServer.GoogleAnalytics package, version 4.0, in which you can now display GA4 analytics data on your site. And note that with this version 4.0, you will only be able to use it with a Google Analytics account that has already added the GA4 property. Instructions for migrating data from Universal Analytics to Google Analytics 4 can be found here.
* Install from Optimizely nuget
Setting up tracking script
* Add MeasurementId:
Step 1: Get your MeasurementId:
Go to Google Analytics > Admin > Data Streams > Web stream details > Stream details > Copy MEASUREMENT ID
Step 2: Add your MeasurementId to your site:
Go to Edit Mode > Addons > GoogleAnalytics > Admin > Configure Tracking > All Sites > Select Google Analytics 4 > Paste MEASUREMENT ID
* Custom Tracking Script:
Go to Edit Mode > Addons > GoogleAnalytics > Admin > Configure Tracking > All Sites > Select Custom Tracking Script > Paste this code with your MeasurementId:
Enable debug mode
To monitor events from your website as Analytics collects them in DebugView of Google Analytics, add this code in Startup.cs
For more details about the configuration, you can refer to our online documentation