Skip to content
Snippets Groups Projects
Commit 0d6ad6f9 authored by wbazant's avatar wbazant
Browse files

Do not pollute global scope - enables Google Analytics to work correctly

Google tells you to use analytics by including this snippet:
<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','https://www.google-analytics.com/analytics.js','ga');

  ga('create','unique tracker id', 'auto');
  ga('send', 'pageview');
</script>

i[r] is window['ga'] and if it's something truthy ([] is truthy) the snippet does nothing.

At the same time foundationExtendEBI.js can not rely on window.ga being there (individual teams will have their own tracker, or not) so add an if-exists-then before each function call.
parent 34e74faa
No related branches found
Tags v1.3.0-beta.4
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment