Module: Card::Set::All::GoogleAnalytics::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- tmpsets/set/mod027-google_analytics/all/google_analytics.rb
Instance Method Summary collapse
- #google_analytics_key ⇒ Object
- #google_analytics_snippet_javascript ⇒ Object
- #google_analytics_snippet_vars ⇒ Object
- #google_analytics_snippet_vars_string ⇒ Object
- #views_in_head ⇒ Object
Instance Method Details
#google_analytics_key ⇒ Object
19 20 21 |
# File 'tmpsets/set/mod027-google_analytics/all/google_analytics.rb', line 19 def google_analytics_key @google_analytics_key ||= Card.global_setting :google_analytics_key end |
#google_analytics_snippet_javascript ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'tmpsets/set/mod027-google_analytics/all/google_analytics.rb', line 36 def google_analytics_snippet_javascript <<-JAVASCRIPT var _gaq = _gaq || [];#{"\n" + google_analytics_snippet_vars_string} (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); })(); JAVASCRIPT end |
#google_analytics_snippet_vars ⇒ Object
23 24 25 26 |
# File 'tmpsets/set/mod027-google_analytics/all/google_analytics.rb', line 23 def google_analytics_snippet_vars [[:_setAccount, google_analytics_key], [:_trackPageview]] end |
#google_analytics_snippet_vars_string ⇒ Object
28 29 30 31 32 33 34 |
# File 'tmpsets/set/mod027-google_analytics/all/google_analytics.rb', line 28 def google_analytics_snippet_vars_string google_analytics_snippet_vars.map do |array| <<-JAVASCRIPT _gaq.push([#{array.map { |i| "'#{i}'" }.join ', '}]); JAVASCRIPT end.join end |
#views_in_head ⇒ Object
10 11 12 |
# File 'tmpsets/set/mod027-google_analytics/all/google_analytics.rb', line 10 def views_in_head super << :google_analytics_snippet end |