Module: Bacchanalytics::GoogleAnalytics::TrackingCode
- Included in:
- Analytics
- Defined in:
- lib/bacchanalytics/google_analytics.rb
Instance Method Summary collapse
-
#google_analytics_tracking_code(web_property_id, domain_name = nil) ⇒ Object
Construct the new asynchronous version of the Google Analytics code.
- #ignored_organic_script ⇒ Object
Instance Method Details
#google_analytics_tracking_code(web_property_id, domain_name = nil) ⇒ Object
Construct the new asynchronous version of the Google Analytics code. code.google.com/apis/analytics/docs/tracking/asyncTracking.html
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bacchanalytics/google_analytics.rb', line 35 def google_analytics_tracking_code(web_property_id, domain_name = nil) <<-SCRIPT <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{web_property_id}']); if ('#{domain_name}' !== ''){ _gaq.push(['_setDomainName', '#{domain_name}']); } #{ignored_organic_script} _gaq.push(['_trackPageview']); #{load_ga_src} </script> SCRIPT end |
#ignored_organic_script ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bacchanalytics/google_analytics.rb', line 52 def ignored_organic_script script = "" begin if @ignored_organic.is_a?(Array) @ignored_organic.each { |item| script << <<-CODE _gaq.push(['_addIgnoredOrganic', '#{item}']); CODE } elsif @ignored_organic.is_a?(String) script << <<-CODE _gaq.push(['_addIgnoredOrganic', '#{@ignored_organic}']); CODE end rescue end script end |