ruby - Keep google analytics tracking id confidential Rails 4 -


my question within google analytics how keep ga_tracking_id out of source code ? tried achieve through environment variable value of key in source see. here relevant code.

production.rb

config.ga_tracking_id = env['ga_tracking_id'] 

application.html.erb

<%# google analytics (only in production environments) %>     <% if rails.env.production? %>         <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', '<%= rails.configuration.ga_tracking_id %>', 'auto');           ga('send', 'pageview');         </script>     <% end %> 

then set key configuration @ heroku

heroku config:set ga_tracking_id=ua-xxxxxxxx-2 

now google analytics working tracking id still in source. why keys value in source ? , how can keep confidential ?

i still quite new application development of kind, have been teaching myself through online resources 8 months, ror! appreciated thanks.

it's impossible hide google analytics tracking id. google requires in plain text, if crypted in way, request made google analytics, viewable chrome dev tools, contain ga_tracking_id in plain text.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -