middleman-google-tag-manager 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62fc70fc72c231ee1d8fce2b2bd145be471ba9cd
4
+ data.tar.gz: 210e745a7ce6a02aaa6dbc230e1bf6f6d44d1352
5
+ SHA512:
6
+ metadata.gz: 368caad7798da61caf81508a9df5865f85925c1c8dd20563e246f0f2a4f58e4236fe08464e2366a116d28174d79a9fa2a8b0acfcd0410844f4cef8fb65a56b3f
7
+ data.tar.gz: fcad45fa88be20a4bb73e7ae5faa2cddcc43770e0845da145bea4bf0a2b1577a2611777a1af055a58350c70a24e22a7666acb04941aacee934c44149395d6c5d
@@ -0,0 +1,7 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
6
+
7
+ .env
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in middleman-foxycart.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rake'
8
+ gem 'rdoc'
9
+ gem 'yard'
10
+ end
11
+
12
+ group :test do
13
+ gem 'cucumber'
14
+ gem 'aruba'
15
+ gem 'rspec'
16
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Robert Coleman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # middleman-google-tag-manager
2
+
3
+ A [Middleman](https://middlemanapp.com) extension for use with [Google Tag Manager](https://www.google.com/analytics/tag-manager/).
4
+
5
+ __Features__
6
+
7
+ * Automatically places Google Tag Manager code on all configured pages.
8
+
9
+
10
+ ## Setup and Configuration
11
+
12
+ In `config.rb`
13
+
14
+ ```ruby
15
+ activate :google_tag_manager do |gtm|
16
+ gtm.container_id = 'your Google Tag Manager container ID' # required
17
+ gtm.development = true # Render tag in development environment
18
+ end
19
+ ```
20
+
21
+ ## Helper and Usage
22
+
23
+ Examples for ERB templates:
24
+
25
+ ```ruby
26
+ <%= google_tag_manager %>
27
+ # e.g. use in layout.erb
28
+ ```
29
+
30
+ ## See also
31
+
32
+ * Google Analytics https://github.com/danielbayerlein/middleman-google-analytics - (several ideas taken from here :)
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = '--color --tags ~@wip --strict'
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-google-tag-manager')
@@ -0,0 +1,53 @@
1
+ require 'middleman-core'
2
+
3
+ class GoogleTagManager < ::Middleman::Extension
4
+ option :container_id, ENV['GTM_CONTAINER_ID'], 'Google Tag Manager container ID'
5
+ option :development, true, 'Render tag in development environment'
6
+
7
+ def after_configuration
8
+ unless options.container_id
9
+ $stderr.puts 'Google Tag Manager: Please specify a container ID'
10
+ raise ArgumentError, 'No container ID given' if display?
11
+ end
12
+ end
13
+
14
+ helpers do
15
+ def google_tag_manager
16
+ options = extensions[:google_tag_manager].options
17
+ return unless !legacy_development? && options.development
18
+
19
+ @text ||= <<-END.gsub(/^ {8}/, '')
20
+ <!-- Google Tag Manager -->
21
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=#{options.container_id}"
22
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
23
+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
24
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
25
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
26
+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
27
+ })(window,document,'script','dataLayer','#{options.container_id}');</script>
28
+ <!-- End Google Tag Manager -->
29
+ END
30
+ end
31
+
32
+ # Support for Middleman >= 3.4
33
+ def legacy_development?
34
+ # Middleman 3.4
35
+ is_development = try(:development?)
36
+ unless is_development.nil?
37
+ return is_development
38
+ end
39
+
40
+ # Middleman 4.x
41
+ app.development?
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def display?
48
+ app.build? || app.development? && options.development
49
+ end
50
+
51
+ end
52
+
53
+ GoogleTagManager.register(:google_tag_manager)
@@ -0,0 +1 @@
1
+ require 'middleman-google-tag-manager'
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'middleman-google-tag-manager'
6
+ s.version = '0.1.0'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Robert Coleman']
9
+ s.email = ['github@robert.net.nz']
10
+ s.homepage = 'https://github.com/rjocoleman/middleman-google-tag-manager'
11
+ s.summary = %q{Google Tag Manager for Middleman static sites}
12
+ s.description = %q{Google Tag Manager for Middleman static sites}
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_runtime_dependency 'middleman-core', '>= 3.4.0'
21
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-google-tag-manager
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Coleman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.4.0
27
+ description: Google Tag Manager for Middleman static sites
28
+ email:
29
+ - github@robert.net.nz
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - features/support/env.rb
40
+ - lib/middleman-google-tag-manager.rb
41
+ - lib/middleman_extension.rb
42
+ - middleman-google-tag-manager.gemspec
43
+ homepage: https://github.com/rjocoleman/middleman-google-tag-manager
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.5.1
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Google Tag Manager for Middleman static sites
67
+ test_files:
68
+ - features/support/env.rb
69
+ has_rdoc: