javascript - How to skip Google Analytics loading? - Stack Overflow

Turkish government have blocked some IPs including Google Analytics. This caused all the web sites usin

Turkish government have blocked some IPs including Google Analytics. This caused all the web sites using alanytics to slow down and even not to load. How can we prevent this problem? How can we skip loading of ga.js if not available?

Turkish government have blocked some IPs including Google Analytics. This caused all the web sites using alanytics to slow down and even not to load. How can we prevent this problem? How can we skip loading of ga.js if not available?

Share Improve this question asked Jun 8, 2010 at 9:54 HasanGHasanG 13.2k31 gold badges102 silver badges159 bronze badges 2
  • 3 An interesting close vote. I would consider external javascript loading questions to be programming related, and that's exactly what this problem is. – Andy E Commented Jun 8, 2010 at 10:00
  • Maybe serverfault but I wouldn't think superuser. – Douglas Leeder Commented Jun 8, 2010 at 10:02
Add a ment  | 

4 Answers 4

Reset to default 6

Google offers an asynchronous snippet for their tracking code:

Note that you need to use a different tracking syntax to use it, check the migration guide on the link for details. It also require a browser with support for the HTML5 attribute 'async', so it may not fully solve your problem.

Another solution is proposed in 'Better Google Analytics JavaScript that doesn't block page downloading'

You could try using the defer attribute on a script element to delay loading until the document has been fully parsed.

<script src="http://www.google./path/to/analytics.js" 
        type="text/javascript"
        defer>
</script>

I'm not sure if this would affect the analytics scripts adversely, though.

As an aside, the defer attribute is available in newer versions of Firefox, IE6+, Chrome, Safari, Opera.

It depends how the Turkish government is blocking:

  1. Connections hang
  2. Connections are refused
  3. Packets just black-hole

It's probably 3), so you'll have to detect Turkish IPs and write the page differently to not reference google to fix the problem. At least that's the only solution I can think of at the moment.

You can try using the loading the GA script asynchronously

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744161845a4561129.html

相关推荐

  • javascript - How to skip Google Analytics loading? - Stack Overflow

    Turkish government have blocked some IPs including Google Analytics. This caused all the web sites usin

    9天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信