Module: Helpers

Defined in:
lib/optimize_ab/helpers.rb

Instance Method Summary collapse

Instance Method Details

#mv_begin_section(name) ⇒ Object

Multi-Variate Page Sections Scripts ########



42
43
44
45
46
47
# File 'lib/optimize_ab/helpers.rb', line 42

def mv_begin_section(name)
  js = "    <script>utmx_section(\"\#{name}\")</script>\n  HTML\n  return js.html_safe\nend\n"

#mv_end_sectionObject



49
50
51
52
53
54
# File 'lib/optimize_ab/helpers.rb', line 49

def mv_end_section
  js = "    </noscript>\n  HTML\n  return js.html_safe\nend\n"

#mv_head(k, ua, pv) ⇒ Object

Multi-Variate Control / Tracking Script / Click Function ########



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/optimize_ab/helpers.rb', line 5

def mv_head(k, ua, pv)
  js = "    <script>\n      function utmx_section(){}function utmx(){}\n      (function(){var k=\"\#{k}\",d=document,l=d.location,c=d.cookie;function f(n){\n      if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return escape(c.substring(i+n.\n      length+1,j<0?c.length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;\n      d.write('<sc'+'ript src=\"'+\n      'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'\n      +'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='\n      +new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+\n      '\" type=\"text/javascript\" charset=\"utf-8\"></sc'+'ript>')})();\n    </script>\n    <script type=\"text/javascript\">\n      var _gaq = _gaq || [];\n      _gaq.push(['gwo._setAccount', \"\#{ua}\"]);\n      _gaq.push(['gwo._trackPageview', \"\#{'/' + pv.to_s + '/test'}\"]);\n      function doGoal(that) {\n       try {\n        _gaq.push(['gwo._trackPageview', \"\#{'/' + pv.to_s + '/goal'}\"]);\n        setTimeout('document.location = \"' + that.href + '\"', 100)\n       }\n       catch(err){}\n      }\n      (function() {\n        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n      })();\n    </script>\n  HTML\n  return js.html_safe\nend\n"