title: Keep google analytics tracking id confidential Rails 4
body: <p>My question is within Google Analytics how do i keep the ga_tracking_id out of the source code ?
  I tried to achieve this through an environment variable but the value of the key is in the source for everybody to see. Here is the relevant code.</p>
  
  <p>production.rb</p>
  
  <pre><code>config.ga_tracking_id = ENV['GA_TRACKING_ID']
  </code></pre>
  
  <p>application.html.erb</p>
  
  <pre><code>&lt;%# Google Analytics (only in production environments) %&gt;
      &lt;% if Rails.env.production? %&gt;
          &lt;script&gt;
            (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', '&lt;%= Rails.configuration.ga_tracking_id %&gt;', 'auto');
            ga('send', 'pageview');
          &lt;/script&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>Then i set the key configuration at heroku</p>
  
  <pre><code>heroku config:set GA_TRACKING_ID=UA-xxxxxxxx-2
  </code></pre>
  
  <p>Now the google analytics is working but the tracking id is still in the source. Why is the keys value in the source ? and how can i keep it confidential ?</p>
  
  <p>I am still quite new to application development of any kind, i have been teaching myself through online resources for about 8 months, mainly RoR!
  Any help would be much appreciated thanks. </p>