jekyll-google-tag-manager 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +51 -0
- data/lib/jekyll-google-tag-manager.rb +56 -0
- data/lib/jekyll-google-tag-manager/version.rb +8 -0
- data/lib/template-body.html +4 -0
- data/lib/template-head.html +7 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aa60c887da9484f6fc4ea402a8aa9794afe4bcc9
|
4
|
+
data.tar.gz: 963b365f91a44530e17ec5a8582bbace7c850d3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56a236f9d93299e2d766addef75f276fee2090c60a8b420334dd19233aabbc21bfb95d6e30d22b02fb1cb3b2363bf877a15d1ac8da2bfd6958702dbba96f6b3f
|
7
|
+
data.tar.gz: c572756dbc29ad1ef71e75658460fade466570e913f0c4963410a01c2ec189898559b2f94676daf0d85d7b5db1ae91213cf2d379c34ccf814f66b81d1588d9c7
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Tom Richards
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Jekyll Google Tag Manager Plugin
|
2
|
+
|
3
|
+
A Jekyll plugin to insert [Google Tag Manager][gtm] tags into the head and body of your site.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the plugin to your site's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :jekyll_plugins do
|
11
|
+
gem 'jekyll-google-tag-manager'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
You must specify a single GTM container in your site's `_config.yml`.
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
google:
|
27
|
+
tag_manager:
|
28
|
+
container_id: GTM-NNNNNNN
|
29
|
+
```
|
30
|
+
|
31
|
+
Add the following right after the opening of the `<head>` tag in your site template(s):
|
32
|
+
|
33
|
+
```liquid
|
34
|
+
{% gtm head %}
|
35
|
+
```
|
36
|
+
|
37
|
+
Add the following right after the opening of the `<body>` tag in your site template(s):
|
38
|
+
|
39
|
+
```liquid
|
40
|
+
{% gtm body %}
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/t-richards/jekyll-google-tag-manager.
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
50
|
+
|
51
|
+
[gtm]: https://www.google.com/analytics/tag-manager/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "jekyll-google-tag-manager/version"
|
2
|
+
require "liquid"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class GoogleTagManager < Liquid::Tag
|
6
|
+
attr_accessor :context
|
7
|
+
|
8
|
+
def initialize(_tag_name, text, _tokens)
|
9
|
+
super
|
10
|
+
@text = text.strip
|
11
|
+
end
|
12
|
+
|
13
|
+
def render(context)
|
14
|
+
@context = context
|
15
|
+
template.render!(payload, info)
|
16
|
+
end
|
17
|
+
|
18
|
+
def template
|
19
|
+
@template ||= Liquid::Template.parse template_contents
|
20
|
+
end
|
21
|
+
|
22
|
+
def options
|
23
|
+
{
|
24
|
+
"version" => Jekyll::GoogleTagManager::VERSION
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def payload
|
29
|
+
{
|
30
|
+
"container_id" => context.registers[:site].config["google"]["tag_manager"]["container_id"],
|
31
|
+
"gtm_tag" => options
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def info
|
36
|
+
{
|
37
|
+
:registers => context.registers,
|
38
|
+
:filters => [Jekyll::Filters]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def template_contents
|
43
|
+
@template_contents ||= begin
|
44
|
+
File.read(template_path)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def template_path
|
49
|
+
@template_path ||= begin
|
50
|
+
File.expand_path("./template-#{@text}.html", File.dirname(__FILE__))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Liquid::Template.register_tag("gtm", Jekyll::GoogleTagManager)
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<!-- Begin Jekyll GTM tag v{{ gtm_tag.version }} -->
|
2
|
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ container_id }}"
|
3
|
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
4
|
+
<!-- End Jekyll GTM tag v{{ gtm_tag.version }} -->
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!-- Begin Jekyll GTM tag v{{ gtm_tag.version }} -->
|
2
|
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
3
|
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
4
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
5
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
6
|
+
})(window,document,'script','dataLayer','{{ container_id }}');</script>
|
7
|
+
<!-- End Jekyll GTM tag v{{ gtm_tag.version }} -->
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-google-tag-manager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Richards
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- tom@tomrichards.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- lib/jekyll-google-tag-manager.rb
|
79
|
+
- lib/jekyll-google-tag-manager/version.rb
|
80
|
+
- lib/template-body.html
|
81
|
+
- lib/template-head.html
|
82
|
+
homepage: https://github.com/t-richards/jekyll-google-tag-manager
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
allowed_push_host: https://rubygems.org
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.5.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A Jekyll plugin to add Google Tag Manager snippets to your site.
|
107
|
+
test_files: []
|