How to disable google analytics on localhost?
@pietro
To disable Google Analytics on localhost, you can follow these steps:
1 2 3 4 5 6 7 |
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_GA_TRACKING_ID');
</script>
|
1 2 3 4 5 6 7 |
<!--<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_GA_TRACKING_ID');
</script>-->
|
Note: Remember to uncomment or add back the Google Analytics tracking code when deploying your website to a live server for production use.