Removing spam referrals in Google Analytics doesn't work anymore for some referrers

假如想象 提交于 2019-12-06 15:36:36

The method I found the best was to use custom dimension as the filter.

The "spam" is not spam on your page, it's only your GA-code that is used on a different page.
Since the "spam" is never on your page they can't know what dimension or how to use it.
So..

In your Javascript code add a dimension like:

<script>
   (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','//www.google-analytics.com/analytics.js','ga');

   ga('create', XXXXXXX, 'auto');
   ga('send', 'pageview', {
      'dimension1':  'true'
   });

</script>

This sends a custom dimension with the value "true". In Analytics you add it to the Custom Definitions -> Custom Dimensions.

Then in filtering you INCLUDE on this custom dimension if it contains "true" value.
So only data with a Custom Dimension1 with value "true" is counted. If the spammers finds this out.
Then they are good :-)

This way you will only get true data on Google Analytics and no strange referals.
I have had this running for about a year on my page now and have no strange referals anymore.
All referals I have in GA is true referals.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!