How to add Google Analytics 4 to Shopify
Google recently released version of Google Analytics. This release includes new machine learning/AI-enabled features designed to make it easier to understand user behavior on a site. Here's a few highlights from announcement on the Google Analytics blog from October 14:
To help you get better ROI from your marketing for the long term, we're creating a new, more intelligent Google Analytics that builds on the foundation of the App + Web property we introduced in beta last year.
Smarter insights to improve your marketing decisions and get better ROI By applying Google’s advanced machine learning models, the new Analytics can automatically alert you to significant trends in your data - like products seeing rising demand because of new customer needs.
As of this writing, Shopify has not released any updates on the existing Google Analytics configuration built into the platform. Naturally, the question has been posed on the Shopify forums and there's not a good solution yet.
Google provides instructions for both upgrading existing GA accounts and configuring new accounts for Google Analytics v 4. The wizard cannot transfer data using existing tags from Shopify due to the existing Shopify/GA configuration.
After upgrading to GA 4, a new tag must be installed manually in the Shopify theme. This tag includes the Measurement ID and is similar to the Tracking ID. It should look similar to this and should be pasted just before the closing tag, generally in the theme.js file:
After installing, go to the site to check that it's installed. Google Analytics should pickup the tag event quickly in the Realtime section.
I made a test purchase and did not see the activity in the new GA4 account within the first 20 minutes, while it did show up on the old GA account. A GA help page indicates the old tagging method should work on this version as well:
Note: The schema for Ecommerce events is backwards compatible. If you instrumented your site before Google Analytics 4, no changes are required. However, It is strongly recommend that all new implementations use the format in this guide.
I'm looking into this further and will update with more info. Feel free to share your own experience with configuring Shopify for Google Analytics 4.