Module: OmnitureRails3::ViewHelper

Defined in:
app/helpers/omniture_rails3/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#omniture_htmlObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/omniture_rails3/view_helper.rb', line 3

def omniture_html
  <<-EOS
  <!-- SiteCatalyst code version: H.1. Copyright 1997-2005 Omniture, Inc. More info available at http://www.omniture.com -->
  <script language="JavaScript"><!--
    #{omniture_javascript}
    //--></script>
    <script language="JavaScript"><!--
    if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
    //--></script><noscript><img
    src="#{OmnitureRails3.config.noscript_img_src}"
    height="1" width="1" border="0" alt="" /></noscript><!--/DO NOT REMOVE/-->
    <!-- End SiteCatalyst code version: H.1. -->
  EOS
end

#omniture_javascriptObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/omniture_rails3/view_helper.rb', line 18

def omniture_javascript
  <<-EOS
  var s_account="#{OmnitureRails3.config.}";
  var s=s_gi(s_account);

  $.extend(s, #{sprops_json})

  /* WARNING: Changing the visitor namespace will cause drastic changes
  to how your visitor data is collected.  Changes should only be made
  when instructed to do so by your account manager.*/
  s.visitorNamespace="#{OmnitureRails3.config.visitor_namespace}"

  /************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
  var s_code=s.t();if(s_code)document.write(s_code)
  EOS
end

#sprops_jsonObject



35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/omniture_rails3/view_helper.rb', line 35

def sprops_json
  sprops = Higml.values_for(omniture_input, OmnitureRails3::TREES[controller_name.to_sym], self, omniture_priority_map || {})
    
  transform_sprops(sprops)
  
  sprops.delete_if{|k,v| !v}.
    inject({}){|return_value, value| return_value[value[0]] = h(value[1]); return_value }. #html escape
    to_json.
    gsub(/,\s*"/,",\n\"") #put each variable on a separate line
end

#transform_sprops(sprops) ⇒ Object



46
47
48
49
50
51
52
# File 'app/helpers/omniture_rails3/view_helper.rb', line 46

def transform_sprops(sprops)
  OmnitureRails3.config.prop_map.each do |internal_name, omniture_name|
    sprops[omniture_name] = sprops[internal_name]
    sprops.delete(internal_name)
  end
  sprops
end