Class: Consently::Providers::GoogleTagManager
- Defined in:
- lib/consently/providers/google_tag_manager.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #noscript ⇒ Object
-
#scripts ⇒ Object
None of its own: whatever it loads brings its own cookies, so list those tags here as well if you manage them through the container.
Methods inherited from Base
build, cookie, cookie_manifest, #cookies, #initialize, provider_key, provider_key=, register, registry, #to_s
Constructor Details
This class inherits a constructor from Consently::Providers::Base
Instance Method Details
#noscript ⇒ Object
19 20 21 |
# File 'lib/consently/providers/google_tag_manager.rb', line 19 def noscript %(<iframe src="https://www.googletagmanager.com/ns.html?id=#{id}" height="0" width="0" style="display:none;visibility:hidden"></iframe>) end |
#scripts ⇒ Object
None of its own: whatever it loads brings its own cookies, so list those tags here as well if you manage them through the container.
10 11 12 13 14 15 16 17 |
# File 'lib/consently/providers/google_tag_manager.rb', line 10 def scripts [ Script.new(inline: <<~JS.strip) ] (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'}); var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','#{id}'); JS end |