title: Google Analytics Code - Is the correct place to put it in an MVC 5 app?
body: <p>I have an MVC 5 app. I have the Google Analytics code and the tracking code in a separate .js file as follows:</p>
  
  <pre><code>// Google Analytics code
  (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', '-------------', 'auto');
  ga('send', 'pageview');
  
  // Google Analytics tracking code
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '-------------']);
  _gaq.push(['_trackPageview']);
  
  (function () {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  </code></pre>
  
  <p>This .js file is in my BundleConfig.cs file as follows:</p>
  
  <pre><code>    bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                  "~/Scripts/Misc/googleAnalytics.js",
                  "~/Scripts/modernizr-*"
                  ));
  </code></pre>
  
  <p>In my _Layout.cshtml file, I have the BundleConfig file referenced as follows:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  
      &lt;meta http-equiv="no-cache"&gt;
      &lt;meta http-equiv="Expires" content="-1"&gt;
      &lt;meta http-equiv="Cache-Control" content="no-cache"&gt;
  
      &lt;title&gt;&lt;/title&gt;
      @Styles.Render("~/Content/css")
      @Scripts.Render("~/bundles/modernizr")
  &lt;/head&gt;
  </code></pre>
  
  <p>Does this look correct? I want to make sure this is working as it's supposed to.</p>