Class: TheTracker::Trackers::Gtm
- Defined in:
- lib/the_tracker/trackers/gtm.rb
Instance Attribute Summary collapse
-
#data_layer ⇒ Object
writeonly
Sets the attribute data_layer.
Attributes inherited from Base
Instance Method Summary collapse
- #add_data_layer(data, value) ⇒ Object
- #body_top ⇒ Object
-
#initialize(options) ⇒ Gtm
constructor
Gtm info.
- #name ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options) ⇒ Gtm
Gtm info
8 9 10 11 |
# File 'lib/the_tracker/trackers/gtm.rb', line 8 def initialize() @gtmid = [:gtmid] super() end |
Instance Attribute Details
#data_layer=(value) ⇒ Object
Sets the attribute data_layer
5 6 7 |
# File 'lib/the_tracker/trackers/gtm.rb', line 5 def data_layer=(value) @data_layer = value end |
Instance Method Details
#add_data_layer(data, value) ⇒ Object
33 34 35 |
# File 'lib/the_tracker/trackers/gtm.rb', line 33 def add_data_layer(data, value) data_layer[data] = value end |
#body_top ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/the_tracker/trackers/gtm.rb', line 17 def body_top return if !active " \#{show_data_layer}\n <!-- Google Tag Manager -->\n <noscript><iframe src=\"//www.googletagmanager.com/ns.html?id=\#{@gtmid}\"\n height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe></noscript>\n <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','\#{@gtmid}');</script>\n <!-- End Google Tag Manager -->\n EOF\nend\n" |
#name ⇒ Object
13 14 15 |
# File 'lib/the_tracker/trackers/gtm.rb', line 13 def name :gtm end |