Class: Mokio::GaScriptGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Mokio::GaScriptGenerator
- Defined in:
- lib/generators/mokio/ga_script_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#create_script ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/mokio/ga_script_generator.rb', line 7 def create_script script = <<TEXT (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', '#{uid}', 'auto'); ga('send', 'pageview'); TEXT Mokio::ExternalScript.create(:name => "Google Analytics", :script =>script) end |
#create_view ⇒ Object
20 21 22 23 |
# File 'lib/generators/mokio/ga_script_generator.rb', line 20 def create_view puts "Paste it into your layout body: " + "= render :partial => 'frontend/layout_elements/google_analytics'".green template "_google_analytics.html.slim", "app/views/frontend/layout_elements/_google_analytics.html.slim" end |