Class: TheTracker::Trackers::GAnalytics
- Defined in:
- lib/the_tracker/trackers/g_analytics.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_custom_var(index, name, value, scope) ⇒ Object
- #add_transaction(tid = 0, store = '', total = 0, tax = 0, shipping = 0, city = '', state = '', country = '') ⇒ Object
- #add_transaction_item(sku = '', product = '', category = '', price = 0, quantity = 0) ⇒ Object
- #header ⇒ Object
-
#initialize(options) ⇒ GAnalytics
constructor
Analytics uat.
- #name ⇒ Object
- #track_event(category, action, label = '', value = 0, non_interactive = false) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options) ⇒ GAnalytics
Analytics uat
6 7 8 9 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 6 def initialize() @options = super() end |
Instance Method Details
#add_custom_var(index, name, value, scope) ⇒ Object
24 25 26 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 24 def add_custom_var(index, name, value, scope) custom_vars[index] = [name, value, scope] end |
#add_transaction(tid = 0, store = '', total = 0, tax = 0, shipping = 0, city = '', state = '', country = '') ⇒ Object
15 16 17 18 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 15 def add_transaction(tid=0, store='', total=0, tax=0, shipping=0, city='', state='', country='') tid = Time.now.to_i if (tid.nil?) or (tid.to_s == '0') @transaction = Transaction.new(tid, store, total, tax, shipping, city, state, country) end |
#add_transaction_item(sku = '', product = '', category = '', price = 0, quantity = 0) ⇒ Object
20 21 22 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 20 def add_transaction_item(sku='', product='', category='', price=0, quantity=0) @transaction.add_item(sku, product, category, price, quantity) end |
#header ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 32 def header return if !active <<-EOF <script type="text/javascript">//<![CDATA[ var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{@options[:id]}']); #{extra_conf} _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> EOF end |
#name ⇒ Object
11 12 13 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 11 def name :ganalytics end |
#track_event(category, action, label = '', value = 0, non_interactive = false) ⇒ Object
28 29 30 |
# File 'lib/the_tracker/trackers/g_analytics.rb', line 28 def track_event(category, action, label='', value=0, non_interactive=false) "_gaq.push(['_trackEvent', '#{category}', '#{action}', '#{label}', #{value}, #{non_interactive}]);" end |