revolunet / angular-google-analytics

Google Analytics tracking for your AngularJS apps
MIT License
652 stars 172 forks source link

Best way to prevent data being sent for specific users or situation ? #158

Open ervinebalo opened 8 years ago

ervinebalo commented 8 years ago

I am building a web app and I am the dev and the admin of the site.

During dev, I don't my browsing data to be sent to GA. Unless, of course, I am testing new tracking implementation.

Then in the production site, while administering the site, what's the best way for me to not send my growing data? I know in GA I can filter IP addresses but that won't work for me because I have users under the same network that I would like their browsing data tracked.

Thanks!

Toxantron commented 8 years ago

Is your web app build as an SPA? The module comes with an opt-out feature and offline mode and my suggestion would be to use server side scripting to set some configuration variables. Either by adding GET variables to the page you bookmark as admin or by simply having an additional index page.

In index.html

<script>
  var optOut = true;
</script>

<!-- or with PHP -->
<script>
  var optOut = <?php echo isset($_GET['disable']) ? "true" : "false" ?>;
</script> 

In your app.js:

AnalyticsProvider.startOffline(optOut);