In this article you will learn how to create a new Google Analytics Account, add the Google Analytics tracking ID to your Magento 2 store and test to ensure your tracking is working as expected. This article was written for merchants with very little or no knowledge of Magento 2. Feel free to contact me if you require help or have any questions @alexcorradi.
1. Set up your Google Analytics account & tracking id
- Create or login to your Google Analytics account https://analytics.google.com/.
- Once logged in, click on the admin link
- Create or select an already existing account
- If the account you're after already exists, simply click on Property Settings to get hold of the Tracking ID. This is the ID required to enable Google Analytics tracking in your Magento 2 store.
- If you want to create a new account, click on the Create New Account link
- Then, you must fill out the following mandatory info: Account Name, Website Name and Website URL
- Ensure you then select the following data sharing options and click on Get Tracking ID
- Accept Google's Terms or Service
- Copy your Tracking ID
2. enable google analytics tracking in your magento 2 store
- Login to your Magento 2 store
- Once logged into the admin, go to STORES > CONFIGURATION
- Then, scroll down until you see the SALES tab. Expand the tab and click on GOOGLE API
- Select the relevant Store View. If you have multiple Store Views, and if each Store View has a different domain, I suggest you create a new Google Analytics Accounts for each domain!
- Once you have selected your Store View, expend the Google Analytics tab, set enable to yes, enter your Tracking ID and press the Save Config button
- Clear your Magento caches by clicking on Cache Management link in the pop-up
- Click on the Flush Magento Cache button
Done! Your Magento 2 store is now set up with Google Analytics...
3. ensure Google analytics tracking is working
Don't assume tracking is working! Test it to be sure!
- Go to the frontend of your website i.e alexcorradi.org
- If you're using Google Chrome, check for your Tracking ID in the source code. This can be done by right-clicking (Ctrl + click on mouse cursor if using a Mac) and selecting View Page Source
- Then, search for your Tracking ID i.e UA-20153872-1. This should appear within the Google Analytics snippet in source code
- Then, go back to your Google Analytics account and click on Reporting and then click on the Real-Time tab and Overview. If your tracking is working you will be able to see live data pulling through.