card-mod-google_analytics 0.14 → 0.16
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de74c365d5c25330e6b24b9454b9b580526aa77046ed0020499bbb50380b962
|
4
|
+
data.tar.gz: be2d96154864171ceb8dd23c56dfa48dbef15bc1a68f675dd87f7036e73f659a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a8cde16ad4b5f22b881e6a74fb9433bcde714f93497eedae13953dcb5739ac070fc3962ac7bba1da9c9c84ab315bd350af1e9ef78d57e6b9eae4022dd1886a
|
7
|
+
data.tar.gz: 99c0997514c559e8c8825650cfa853fd133333aa44cc72a01ee5d21ead14fa5185e2b6c5338b0f16d83ebaa2e5e21264e3b766d95f761a13eff748c542a39337
|
data/set/all/google_analytics.rb
CHANGED
@@ -8,20 +8,19 @@ def track_page!
|
|
8
8
|
tracker.pageview tracker_options
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Card.config.google_analytics_key
|
11
|
+
def google_analytics_keys
|
12
|
+
@google_analytics_keys ||= Array.wrap(
|
13
|
+
Card::Rule.global_setting(:google_analytics_key) || Card.config.google_analytics_key
|
14
|
+
)
|
16
15
|
end
|
17
16
|
|
18
17
|
def tracker
|
19
18
|
tracker_key && ::Staccato.tracker(tracker_key) # , nil, ssl: true
|
20
19
|
end
|
21
20
|
|
22
|
-
# can
|
21
|
+
# can have separate keys for web and API
|
23
22
|
def tracker_key
|
24
|
-
Card.config.google_analytics_tracker_key ||
|
23
|
+
Card.config.google_analytics_tracker_key || google_analytics_keys.first
|
25
24
|
end
|
26
25
|
|
27
26
|
def tracker_options
|
@@ -41,14 +40,26 @@ def track_page_from_server?
|
|
41
40
|
end
|
42
41
|
|
43
42
|
format :html do
|
44
|
-
|
43
|
+
basket[:head_views].unshift :google_analytics_snippets
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
delegate :google_analytics_keys, to: :card
|
46
|
+
|
47
|
+
def body_tag klasses=""
|
48
|
+
super { "#{render(:google_analytics_noscript)}\n\n#{yield}" }
|
49
|
+
end
|
50
|
+
|
51
|
+
view :google_analytics_snippets, unknown: true, perms: :none do
|
52
|
+
haml :google_analytics_snippets if google_analytics_keys.present?
|
53
|
+
end
|
54
|
+
|
55
|
+
view :google_analytics_noscript, unknown: true, perms: :none do
|
56
|
+
haml :google_analytics_noscript if google_tag_manager_keys.present?
|
48
57
|
end
|
49
58
|
|
50
|
-
|
51
|
-
|
59
|
+
def google_tag_manager_keys
|
60
|
+
@google_tag_manager_keys ||= google_analytics_keys.find_all do |key|
|
61
|
+
key.match?(/^GTM-/)
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def google_analytics_snippet_vars
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/ Google Tag Manager (noscript)
|
2
|
+
- google_tag_manager_keys.each do |ga_key|
|
3
|
+
%noscript
|
4
|
+
%iframe{ src: "https://www.googletagmanager.com/ns.html?id=#{ga_key}",
|
5
|
+
height: "0",
|
6
|
+
width: "0",
|
7
|
+
style: "display:none;visibility:hidden" }
|
8
|
+
/ End Google Tag Manager (noscript)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/ Google Analytics
|
2
|
+
- google_analytics_keys.each do |ga_key|
|
3
|
+
- case ga_key
|
4
|
+
- when /^UA-/
|
5
|
+
/ Universal Analytics Tag (analytics.js)
|
6
|
+
%script
|
7
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
8
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
9
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
10
|
+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
11
|
+
|
12
|
+
ga('create', '#{ga_key}', 'auto');
|
13
|
+
- google_analytics_snippet_vars.each do |key, value|
|
14
|
+
- value = "'#{value}'" if value.is_a? String
|
15
|
+
ga('set', '#{key}', #{value})
|
16
|
+
ga('send', 'pageview');
|
17
|
+
|
18
|
+
- when /^G-/
|
19
|
+
/ Global site tag (gtag.js)
|
20
|
+
%script{ async: true, src: "https://www.googletagmanager.com/gtag/js?id=#{ga_key}" }
|
21
|
+
%script
|
22
|
+
window.dataLayer = window.dataLayer || [];
|
23
|
+
function gtag(){dataLayer.push(arguments);}
|
24
|
+
gtag('js', new Date());
|
25
|
+
= "gtag('config', '#{ga_key}');"
|
26
|
+
|
27
|
+
- when /^GTM-/
|
28
|
+
/ Google Tag Manager (gtm.js)
|
29
|
+
%script
|
30
|
+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
31
|
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
32
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
33
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
34
|
+
})(window,document,'script','dataLayer','#{ga_key}');
|
35
|
+
|
36
|
+
/ End Google Analytics
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-google_analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.16'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Kühl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: card
|
@@ -49,7 +49,8 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- lib/card/mod/google_analytics.rb
|
51
51
|
- set/all/google_analytics.rb
|
52
|
-
- set/all/
|
52
|
+
- set/all/google_analytics_noscript.haml
|
53
|
+
- set/all/google_analytics_snippets.haml
|
53
54
|
homepage: http://decko.org
|
54
55
|
licenses:
|
55
56
|
- GPL-3.0
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
- !ruby/object:Gem::Version
|
71
72
|
version: '0'
|
72
73
|
requirements: []
|
73
|
-
rubygems_version: 3.2.
|
74
|
+
rubygems_version: 3.2.33
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: Google Analytics support for decko
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/ Google Analytics
|
2
|
-
%script
|
3
|
-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
4
|
-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
5
|
-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
6
|
-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
7
|
-
|
8
|
-
ga('create', '#{google_analytics_key}', 'auto');
|
9
|
-
- google_analytics_snippet_vars.each do |key, value|
|
10
|
-
- value = "'#{value}'" if value.is_a? String
|
11
|
-
ga('set', '#{key}', #{value})
|
12
|
-
ga('send', 'pageview');
|
13
|
-
/ End Google Analytics
|