gtm_on_rails 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.md +2 -1
- data/README.md +3 -2
- data/app/views/gtm_on_rails/layouts/_data_layer_tag.html.erb +8 -3
- data/lib/gtm_on_rails/models/data_layer.rb +8 -3
- data/lib/gtm_on_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d930846667618746fbb6cdbc1f74928f6118006e
|
4
|
+
data.tar.gz: e5ec635f9ac76d4c4f0c3d2f52ef1fe7fa2fec8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2897d0a268ec2d22f5c279d7e6d8da138222174cf8e12daa5a4ebd1eac268f23c448884bea2f7a7d78d0730c7b698e187ef7c045c949f14e617b94b51634fc85
|
7
|
+
data.tar.gz: 118b23cb8e9f61f0db51c0fcf4d5d2a2af16a420596bfe49f4e073ef77ea25880ca71d262c161130a7518005fecfec233b862468acaaf9462120fb46c20096ad
|
data/README.ja.md
CHANGED
data/README.md
CHANGED
@@ -58,13 +58,14 @@ You also can use `GtmOnRails::DataLayerObject` object rather than Hash as the ab
|
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
object = GtmOnRails::DataLayerObject.new({name: 'name'})
|
61
|
-
|
61
|
+
object.name
|
62
|
+
object.name = 'name2'
|
62
63
|
```
|
63
64
|
You can access values with `GtmOnRails::DataLayerObject` object as the above.
|
64
65
|
|
65
66
|
#### `GtmOnRails::DataLayerEvent`
|
66
67
|
```ruby
|
67
|
-
event = GtmOnRails::DataLayerEvent.new('
|
68
|
+
event = GtmOnRails::DataLayerEvent.new('event_name', {name: 'name'})
|
68
69
|
data_layer.push(event)
|
69
70
|
```
|
70
71
|
You can send dataLayer with Google Tag Manager's event name, when write like the above code.
|
@@ -1,7 +1,12 @@
|
|
1
1
|
<% begin %>
|
2
|
-
<%= data_layer.
|
2
|
+
<%= data_layer.print_on_html %>
|
3
3
|
<%-
|
4
|
-
rescue
|
5
|
-
|
4
|
+
rescue => e
|
5
|
+
if GtmOnRails.config.rescue_when_error_occurred
|
6
|
+
logger.warn(e.message)
|
7
|
+
logger.warn(e.backtrace.join("\n"))
|
8
|
+
else
|
9
|
+
raise e
|
10
|
+
end
|
6
11
|
end
|
7
12
|
-%>
|
@@ -22,7 +22,7 @@ module GtmOnRails
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def to_js
|
26
26
|
js_codes = []
|
27
27
|
|
28
28
|
js_codes << "var dataLayer = dataLayer || [];"
|
@@ -30,13 +30,18 @@ module GtmOnRails
|
|
30
30
|
# dataLayer size limit exception
|
31
31
|
size = data_layer_object.to_json.bytesize
|
32
32
|
if size > GtmOnRails.config.data_layer_limit_byte_size
|
33
|
-
|
33
|
+
logger.warn("DataLayer bytesize is over limit #{GtmOnRails.config.data_layer_limit_byte_size} bytes. Size is #{size} bytes.")
|
34
|
+
next
|
34
35
|
end
|
35
36
|
|
36
37
|
js_codes << data_layer_object.to_js
|
37
38
|
end
|
38
39
|
|
39
|
-
return
|
40
|
+
return js_codes.join.html_safe
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_on_html
|
44
|
+
content_tag(:script, self.to_js)
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
data/lib/gtm_on_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtm_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ykogure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|