diff --git a/app/controllers/api/v1/accounts/portals_controller.rb b/app/controllers/api/v1/accounts/portals_controller.rb index 770018e3c..23f87af73 100644 --- a/app/controllers/api/v1/accounts/portals_controller.rb +++ b/app/controllers/api/v1/accounts/portals_controller.rb @@ -79,7 +79,7 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController params.require(:portal).permit( :id, :color, :custom_domain, :header_text, :homepage_link, :name, :page_title, :slug, :archived, - { config: [:default_locale, :layout, { allowed_locales: [] }, { draft_locales: [] }, + { config: [:default_locale, :layout, :gtm_container_id, { allowed_locales: [] }, { draft_locales: [] }, { social_profiles: %i[facebook x instagram linkedin youtube tiktok github whatsapp] }] } ) end diff --git a/app/views/api/v1/accounts/portals/_portal.json.jbuilder b/app/views/api/v1/accounts/portals/_portal.json.jbuilder index 08b3e8b36..2bbda193c 100644 --- a/app/views/api/v1/accounts/portals/_portal.json.jbuilder +++ b/app/views/api/v1/accounts/portals/_portal.json.jbuilder @@ -18,6 +18,7 @@ json.config do json.default_locale portal.default_locale json.layout portal.layout json.social_profiles portal.social_profiles + json.gtm_container_id portal.gtm_container_id end if portal.channel_web_widget diff --git a/app/views/layouts/_portal_analytics.html.erb b/app/views/layouts/_portal_analytics.html.erb new file mode 100644 index 000000000..0812de979 --- /dev/null +++ b/app/views/layouts/_portal_analytics.html.erb @@ -0,0 +1,13 @@ +<%# Google Tag Manager. The container ID is validated against Portal::GTM_CONTAINER_ID_FORMAT, %> +<%# so it is restricted to `GTM-` + alphanumerics and is safe to interpolate here. %> +<% if @portal.gtm_container_id.present? %> + + + +<% end %> diff --git a/app/views/layouts/_portal_analytics_noscript.html.erb b/app/views/layouts/_portal_analytics_noscript.html.erb new file mode 100644 index 000000000..5bb9023e0 --- /dev/null +++ b/app/views/layouts/_portal_analytics_noscript.html.erb @@ -0,0 +1,6 @@ +<% if @portal.gtm_container_id.present? %> + + + +<% end %> diff --git a/app/views/layouts/_portal_head.html.erb b/app/views/layouts/_portal_head.html.erb index a04e09d3f..ca5c2c9d3 100644 --- a/app/views/layouts/_portal_head.html.erb +++ b/app/views/layouts/_portal_head.html.erb @@ -3,6 +3,8 @@ +<%= render 'layouts/portal_analytics' %> + <%= vite_client_tag %> <%= vite_javascript_tag 'portal' %>