How to Exclude Internal Traffics while using Google Analytic App?

using_apps

#1

Hi, everyone!

If I install Google Analytic script via Cloudflare App, how can I exclude internal traffics?

Please guide me an easy way.

Thanks & Regards,
Gulshan


#2

I believe that is something you manage from within your Google Analytics account.

https://support.google.com/analytics/answer/1034840?hl=en

Create an IP address filter
To prevent internal traffic from affecting your data, you can use a filter to filter out traffic by IP address.

You can find the public IP address you are currently using by searching “what is my ip address” on google.com. You can find out what IP addresses and subnets your company uses by asking your network administrator.

To create an IP address filter:

  1. Follow the instructions to create a new filter for your view.
  2. Leave the Filter Type as Predefined.
  3. Click the Select filter type drop-down menu and select Exclude.
  4. Click the Select source or destination drop-down menu and select traffic from the IP addresses.
  5. Click the Select expression drop-down menu and select the appropriate expression.
  6. Enter the IP address or a regular expression. See the examples below.

#3

Hi,

Thanks for your valuable response.

Firstly, I thought to try IP method but there is an issue that I don’t have static IP.
So, indeed I had to look a solution which can work at client side. So, after some research of more than two months, I found a method which resolved my problem. Credit goes to respective team.

<script type="text/javascript" data-cfasync="false">
// Set to the same value as the web property used on the site
var gaProperty = 'UA-xxxxxx-y';

// Disable tracking if the opt-out cookie exists.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
  window[disableStr] = true;
}

// Opt-out function
function gaOptout() {
  document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
  window[disableStr] = true;
}

// Google Analytics
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  
  ga('create', 'UA-xxxxxx-y', 'auto');
  ga('send', 'pageview');
</script>

<a href="javascript:gaOptout()">Click here to opt-out of Google Analytics</a>

I hope that someone can find this tips useful.

Thanks