Add GTM to the settings page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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? %>
|
||||
<!-- Google Tag Manager -->
|
||||
<script>
|
||||
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','<%= j @portal.gtm_container_id %>');
|
||||
</script>
|
||||
<!-- End Google Tag Manager -->
|
||||
<% end %>
|
||||
@@ -0,0 +1,6 @@
|
||||
<% if @portal.gtm_container_id.present? %>
|
||||
<!-- Google Tag Manager (noscript) -->
|
||||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= @portal.gtm_container_id %>"
|
||||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<!-- End Google Tag Manager (noscript) -->
|
||||
<% end %>
|
||||
@@ -3,6 +3,8 @@
|
||||
<meta name="turbolinks-cache-control" content="no-cache">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<%= render 'layouts/portal_analytics' %>
|
||||
|
||||
<%= vite_client_tag %>
|
||||
<%= vite_javascript_tag 'portal' %>
|
||||
<style>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<%= render 'layouts/portal_head' %>
|
||||
</head>
|
||||
<body class="font-inter">
|
||||
<%= render 'layouts/portal_analytics_noscript' %>
|
||||
<div id="portal" class="antialiased">
|
||||
<main class="flex flex-col min-h-screen bg-white main-content dark:bg-slate-900" role="main">
|
||||
<%= render 'public/api/v1/portals/documentation_layout/topbar',
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<%= render 'layouts/portal_head' %>
|
||||
</head>
|
||||
<body class="font-default">
|
||||
<%= render 'layouts/portal_analytics_noscript' %>
|
||||
<div id="portal" class="antialiased">
|
||||
<main class="flex flex-col min-h-screen bg-white main-content dark:bg-slate-900" role="main">
|
||||
<%= render 'public/api/v1/portals/header', portal: @portal unless @is_plain_layout_enabled %>
|
||||
|
||||
Reference in New Issue
Block a user