google_data_layer-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +12 -0
- data/app/helpers/google_data_layer_helper.rb +44 -0
- data/google_data_layer-rails.gemspec +25 -0
- data/lib/google_data_layer/rails/config.rb +13 -0
- data/lib/google_data_layer/rails/version.rb +5 -0
- data/lib/google_data_layer/rails.rb +22 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0828139d476819ec3a587acc34f8d903cc591bd4
|
4
|
+
data.tar.gz: 62ffb0dd4362aea6544a044b70cef0ec4ec4df23
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbd56216b36c72acdefdda74aea14b77d27bfdabc8bff555f2bac4312ac8cb431de53fb463a217d6722b2f7cf993a1e79d5d82aaba6a04d318f37dd4fe6ec85b
|
7
|
+
data.tar.gz: 9e30f13b780f65ffaab111bad63a09dfe697579fa44fe189adc21903a36188d4cdb86bf5165ce5ea5acd023b12b3612cddc7821b41c90777e413d14e1ac5a575
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 carwow
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# GoogleDataLayer::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'google_data_layer-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install google_data_layer-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
desc "Increase the revision number"
|
4
|
+
task :increase_revision_number do
|
5
|
+
version_file = "lib/google_data_layer/rails/version.rb"
|
6
|
+
file_content = File.read(version_file)
|
7
|
+
rule = /(\d+\.\d+\.)(\d+)/
|
8
|
+
new_revision_number = rule.match(file_content)[2].to_i + 1
|
9
|
+
new_file_content = file_content.sub(rule, '\1' + new_revision_number.to_s)
|
10
|
+
|
11
|
+
File.open(version_file, 'w') { |file| file.write(new_file_content) }
|
12
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module GoogleDataLayerHelper
|
2
|
+
def google_data_layer_information(page_name, page_type)
|
3
|
+
@google_data_layer_page_name = page_name
|
4
|
+
@google_data_layer_page_type = page_type
|
5
|
+
end
|
6
|
+
|
7
|
+
def google_data_layer_push_virtual_page_code
|
8
|
+
virtual_page = flash[:data_layer_virtual_page_view_event]
|
9
|
+
if virtual_page
|
10
|
+
"googleDataLayerPushVirtualPageViewEvent('#{virtual_page}');"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def google_data_layer_embed_code
|
15
|
+
%Q{
|
16
|
+
<!-- Google Data Layer -->
|
17
|
+
<script>
|
18
|
+
var googleDataLayer = [{
|
19
|
+
'ga_id': '#{GoogleDataLayer::Rails::Config.google_id}',
|
20
|
+
'page_pageName': '#{@google_data_layer_page_name.to_s}',
|
21
|
+
'page_pageType': '#{@google_data_layer_page_type.to_s}'
|
22
|
+
}];
|
23
|
+
|
24
|
+
var googleDataLayerPushVirtualPageViewEvent = function (pageName) {
|
25
|
+
googleDataLayer.push({
|
26
|
+
'page_virtualName': pageName,
|
27
|
+
'event': 'gtm.view'
|
28
|
+
});
|
29
|
+
}
|
30
|
+
</script>
|
31
|
+
<!-- end Google Data Layer -->
|
32
|
+
|
33
|
+
<!-- Google Tag Manager -->
|
34
|
+
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-57THDK"
|
35
|
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
36
|
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
37
|
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
38
|
+
j=d.createElement(s),dl=l!='googleDataLayer'?'&l='+l:'';j.async=true;j.src=
|
39
|
+
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
40
|
+
})(window,document,'script','googleDataLayer','GTM-57THDK');</script>
|
41
|
+
<!-- End Google Tag Manager -->
|
42
|
+
}.html_safe
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'google_data_layer/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "google_data_layer-rails"
|
8
|
+
spec.version = GoogleDataLayer::Rails::VERSION
|
9
|
+
spec.authors = ["Federico Rebora", "David Santoro"]
|
10
|
+
spec.email = ["developers@carwow.co.uk"]
|
11
|
+
spec.description = %q{Rails helpers to add google data layer javascript to your pages}
|
12
|
+
spec.summary = %q{Rails helpers to add google data layer javascript to your pages}
|
13
|
+
spec.homepage = "https://github.com/carwow/google_data_layer-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "railties"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "google_data_layer/rails/version"
|
2
|
+
require "google_data_layer/rails/config"
|
3
|
+
|
4
|
+
module GoogleDataLayer
|
5
|
+
module Rails
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
initializer "google_data_layer-rails.view_helpers" do
|
8
|
+
ActionView::Base.send :include, GoogleDataLayerHelper
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer "google_data_layer-rails.load_config" do |app|
|
12
|
+
file_path = "#{app.root}/config/google_data_layer.yml"
|
13
|
+
unless File.exist?(file_path)
|
14
|
+
raise "Please create a config file at: #{file_path}"
|
15
|
+
end
|
16
|
+
all_config = YAML.load(File.read(file_path)) || {}
|
17
|
+
env_config = all_config[ENV['RAILS_ENV']] || {}
|
18
|
+
Config.config = env_config
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_data_layer-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Federico Rebora
|
8
|
+
- David Santoro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: Rails helpers to add google data layer javascript to your pages
|
57
|
+
email:
|
58
|
+
- developers@carwow.co.uk
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- app/helpers/google_data_layer_helper.rb
|
69
|
+
- google_data_layer-rails.gemspec
|
70
|
+
- lib/google_data_layer/rails.rb
|
71
|
+
- lib/google_data_layer/rails/config.rb
|
72
|
+
- lib/google_data_layer/rails/version.rb
|
73
|
+
homepage: https://github.com/carwow/google_data_layer-rails
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Rails helpers to add google data layer javascript to your pages
|
97
|
+
test_files: []
|