effective_pages 3.4.9 → 3.4.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5748cf10a1d447f6b636dc8972884464700b3752ed96086e3a16991621b2955a
4
- data.tar.gz: 027050a2f8acd57d4e8170e3a900c02c4dde8c1a3b3f4f2465222dc91525cf5a
3
+ metadata.gz: d47d3c8c168eb5294d42246a5c16c27f37d497511b5daad694b8d3b5327042a6
4
+ data.tar.gz: 3cbd1020565a4a1342674b637aae21dc24c6437d793f804c43a67d711f38f8e7
5
5
  SHA512:
6
- metadata.gz: 3be8ad1c24739aaf895becf0865176d6165cf5ebbf58a3f85b3df02763ef6d59449c298f2ba13c0b0dd6f0dee46828e78112b91a865773b693f330fa48496129
7
- data.tar.gz: 5cdd3c7b4b294c525398d7b3405f042092de6d141d42bcdb175dfdd3eb32926c000fccf9eb3da9cb5f3fd5276188f8615ba5681c78d4931f08cc5716ff5a2a28
6
+ metadata.gz: b0d398a5d2f072fbf27ba6d31fad76703182f8d09ef825c2f0fb7dacf01a448f480bd565011009fd62dde8ad15e50a51c581e7061c45e20bbfe56482eb88eedd
7
+ data.tar.gz: d7b2a8f930af2e52152669681f5329e78ce4dc39d61376f2e4d8b47834e80b60349c6b156ec92d01d736eef11973910b748ca66d063fb5b0dd18eafd0da5cd3a
data/README.md CHANGED
@@ -157,6 +157,23 @@ This provides a mechanism to easily target CSS styles for specific pages.
157
157
 
158
158
  This helper is entirely optional and in no way required for effective_pages to work.
159
159
 
160
+ ### Google Analytics GTag Script Helper
161
+
162
+ Another optional helper. Add the following just after your `<body>` tag:
163
+
164
+ ```haml
165
+ %body
166
+ = effective_pages_google_analytics
167
+ ```
168
+
169
+ This will render the google analytics scripts when running in production mode.
170
+
171
+ Set the GA4 code in your `config/initializers/effective_pages.rb` as so:
172
+
173
+ ```
174
+ config.google_analytics_code = 'G-1234567890'
175
+ ```
176
+
160
177
  ### Permissions
161
178
 
162
179
  When creating a Page, if you've also installed the [effective_roles](https://github.com/code-and-effect/effective_roles) gem, you will be able to configure user access on a per-page basis.
@@ -88,6 +88,15 @@ module EffectivePagesHelper
88
88
  @effective_pages_og_type || 'website'
89
89
  end
90
90
 
91
+ def effective_pages_google_analytics
92
+ return unless Rails.env.production?
93
+
94
+ code = EffectivePages.google_analytics_code
95
+ return unless code.present?
96
+
97
+ render('layouts/google_analytics', code: code)
98
+ end
99
+
91
100
  def application_root_to_effective_pages_slug
92
101
  Rails.application.routes.routes.find { |r| r.name == 'root' && r.defaults[:controller] == 'Effective::Pages' && r.defaults[:action] == 'show' }.defaults[:id] rescue nil
93
102
  end
@@ -0,0 +1,9 @@
1
+ <!-- Google tag (gtag.js) -->
2
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<%= code %>"></script>
3
+ <script>
4
+ window.dataLayer = window.dataLayer || [];
5
+ function gtag(){dataLayer.push(arguments);}
6
+ gtag('js', new Date());
7
+
8
+ gtag('config', '<%= code %>');
9
+ </script>
@@ -47,6 +47,9 @@ EffectivePages.setup do |config|
47
47
  config.silence_missing_meta_description_warnings = false
48
48
  config.silence_missing_canonical_url_warnings = false
49
49
 
50
+ # Google Tag / Google Analytics 4 code
51
+ # config.google_analytics_code = ''
52
+
50
53
  # Display the effective roles 'choose roles' input when an admin creates a new post
51
54
  config.use_effective_roles = false
52
55
 
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.4.9'.freeze
2
+ VERSION = '3.4.10'.freeze
3
3
  end
@@ -10,7 +10,7 @@ module EffectivePages
10
10
  :pages_table_name, :page_sections_table_name, :page_banners_table_name, :carousel_items_table_name,
11
11
  :pages_path, :excluded_pages, :layouts_path, :excluded_layouts,
12
12
  :site_og_image, :site_og_image_width, :site_og_image_height,
13
- :site_title, :site_title_suffix, :fallback_meta_description,
13
+ :site_title, :site_title_suffix, :fallback_meta_description, :google_analytics_code,
14
14
  :silence_missing_page_title_warnings, :silence_missing_meta_description_warnings, :silence_missing_canonical_url_warnings,
15
15
  :use_effective_roles, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.9
4
+ version: 3.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-10 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,6 +112,7 @@ files:
112
112
  - app/views/effective/carousels/_carousel.html.haml
113
113
  - app/views/effective/pages/_menu.html.haml
114
114
  - app/views/effective/pages/_page_menu.html.haml
115
+ - app/views/layouts/_google_analytics.html.erb
115
116
  - config/effective_pages.rb
116
117
  - config/locales/effective_pages.en.yml
117
118
  - config/routes.rb