Permalink
Browse files

Raise exception if there isn't a property id

  • Loading branch information...
1 parent f2f275a commit 0e055c2314d287a7f8cab4ad70b1558cd1c7c7f6 Sebastian von Conrad committed Jan 8, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/in_bed_with/analytics.rb
@@ -7,7 +7,14 @@ def initialize(options={})
end
def code
+ raise ArgumentError, property_id_missing unless property_id
+
"<script type=\"text/javascript\">var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{property_id}']); _gaq.push(['_trackPageview']); (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); })();</script>"
end
+
+ private
+ def property_id_missing
+ 'Please set a Google Analytics Property ID through config.analytics_property_id or by supplying :property_id when calling in_bed_with.analytics.'
+ end
end
end

0 comments on commit 0e055c2

Please sign in to comment.