In order to track the results of your store in Google analytics, you need to generate the code following Google instructions.
After you follow the steps from their tutorial, you will get a code that looks like the following:
1 2 3 4 5 6 7 8 9 10 11 |
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-AAAAA-A']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> |
UA-AAAAA-A is a unique code that was given to your store by Google.
After you generated the code (UA-AAAAA-A), you need to add it on your website. In order to do so, follow a few simple steps.
Log in to your admin panel and navigate directly to Stores => Configuration
Then under Sales, find Google API.
Now click to expand Googla Analytics section, select “Yes” to enable and enter the code (UA-AAAAA-A). Don’t forget to press “Save Config”.
Magento 2 Development
Take your online store to the next level with BelVG Magento 2 Development
Visit the page
Hi, Afroz! Thanks for your question.
The question you asked and many others concerning Google Analytics was addressed in detail in a recent article at our blog How to Set up Magento Google Analytics? Step-by-step Instruction.
How can we link google tag manager into magento website??
Thank you, Damon!
Thanks you have explain this process nicely, and here’s a much simpler and easy to follow tutorial to add Google Analytics on Magento 2 on magenticians I found it very useful too.
This is supported by the core functionality, same as in M1. So, if you did not modify GoogleAnalytics view, it should work out of the box.
Wow, it’s great! Magento 2 rules! So GA code will be added by Magento 2 itself?
@Andrew, now it’s enough to specify your Account Number. GA code will be added after the opening “body” tag automatically.
Hi tezka,
after adding Tracking ID, what about:
“This is the Universal Analytics tracking code for this property.
To get all the benefits of Universal Analytics for this property, copy and paste this code into every webpage you want to track.”
Do I need it on every page also, or Tracking ID is enough?
Regards,
Andrew