What is Google Analytics?
Google Analytics is a free tool from Google. It counts visitors on your website and shows where they come from and what they look at. Magento is a program used to run online shops.
The current version of Google Analytics is called GA4. It gives you a Measurement ID that starts with G-. This ID tells Google which site the numbers belong to.
Step 1: Get your Measurement ID
- Sign in to Google Analytics with your Google account.
- Click Admin (the gear icon).
- Create an account and a property for your store, if you do not have one.
- Under Data collection, choose Data streams.
- Add a Web stream and type your store address.
- Copy the Measurement ID, such as
G-XXXXXXXXXX.
Step 2: Add it in Magento
Magento 2 has a built-in Google Analytics setting. Newer versions may use the Google Tag Manager or an extension for GA4.
- Log in to your Magento admin panel.
- Click Stores in the left menu, then Configuration.
- Open Sales and choose Google API.
- Open the Google Analytics section.
- Set Enable to Yes.
- Paste your Measurement ID in the account box.
- Click Save Config.
- Go to System, then Cache Management, and click Flush Magento Cache.
If your Magento version has no GA4 option, add the tracking code another way:
- Go to Content, then Design, then Configuration.
- Edit your store view and open HTML Head.
- Paste the Google tag code in Scripts and Style Sheets.
- Click Save Configuration and flush the cache.
Back up your store before you paste code. A typing error can break the page.
Step 3: Check it works
- Open your store in another browser tab.
- In Google Analytics, open Reports and then Realtime.
- You should see yourself as a visitor within a minute or two.
If nothing shows
- Check the Measurement ID for typing mistakes.
- Flush the cache again.
- Turn off ad blockers when testing.
Tip: Menu names can change between Magento versions. Need help? Open a ticket at https://secure.hostvento.com/submitticket.php.
Quick recap
- Create a GA4 property and copy the Measurement ID.
- In Magento, go to Stores, Configuration, Sales, Google API.
- Enable Analytics, paste the ID, save and flush the cache.
- Check Realtime in Google Analytics.