This tutorial shows you the steps to setting up Google Analytics for a single store in Magento 2.
However, if you have multiple websites set up in your system, you can pick the store view for which you’re setting it up in the Configuration section.
Step 1. Locate the Configuration Area for Google Analytics
– Go to Stores on the left-hand menu then click on Configuration.
– Scroll down and click on the Sales menu to expand it, and then click on Google API.
– Click on the down arrow located to the right of the Google Analytics section, and then set Enable to Yes.
Step 2. Enter Your Google Analytics Account Number in Magento
– Type analytics.google.com in another browser then press enter on your keyboard.
– That takes you across to your Google Analytics account where you need to get your account number. If you don’t have a Google Analytics account yet, sign up with your Google account then follow the instructions.
– Once you have signed in to your Google Analytics account, copy your account number, which starts with UA and followed by a series of numbers.
– Go back to the Google API settings in your Magento system’s Configuration area, and then paste the number in the field labelled Account Number.
– Advanced users may enable Content Experiments, too, but if you have no idea what this means, just leave it set to No.
Once that’s done, press Save Config in the top right-hand corner.
Step 3. Clear the Caches
– Click on the link Cache Management in the pop-up message along the top of your screen.
– Choose Select All from the drop-down box on the left-hand side and then press Submit.
If your Google Analytics account shows nothing but a straight inactive line as you see above, that’s absolutely normal.
Give Google a couple of hours or a day to actually start showing some tracking information on your website.
If you need a hand at any time, use the contact details below and the forums here are always open.