diff --git a/packages/dotcom-ui-shell/src/__test__/components/GTMHead.test.tsx b/packages/dotcom-ui-shell/src/__test__/components/GTMHead.test.tsx index 91c977c16..2aa970c3b 100644 --- a/packages/dotcom-ui-shell/src/__test__/components/GTMHead.test.tsx +++ b/packages/dotcom-ui-shell/src/__test__/components/GTMHead.test.tsx @@ -7,7 +7,8 @@ describe('dotcom-ui-shell/src/components/GTMHead', () => { const props = { flags: { enableGTM: true - } + }, + appName: 'next-article' } const tree = renderer.create().toJSON() diff --git a/packages/dotcom-ui-shell/src/components/GTMHead.tsx b/packages/dotcom-ui-shell/src/components/GTMHead.tsx index fc3c4e222..0cc0fe3b6 100644 --- a/packages/dotcom-ui-shell/src/components/GTMHead.tsx +++ b/packages/dotcom-ui-shell/src/components/GTMHead.tsx @@ -2,14 +2,25 @@ import React from 'react' import { TFlagsData } from '@financial-times/dotcom-ui-flags/src/types' // This component is maintained by the ads team -const GTMHead = ({ flags }: { flags: TFlagsData }) => { - if (!flags.enableGTM) { - return null - } - - const src = flags['ads-first-party-gtm'] - ? 'https://www.ft.com/page-resources/' - : 'https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68' +type Props = { + flags: TFlagsData + appName?: string +} + +// This component is maintained by the ads team +const GTMHead = ({ flags, appName }: Props) => { + if (!flags.enableGTM) return null + + // 1) If appName is artcile-partner-content use the PC GTM instance + const PCAppOverride = + appName === 'article-partner-content' ? 'https://www.googletagmanager.com/gtm.js?id=GTM-12345' : null + + // 2) If appName is not Partner Content, use the standard FT.com GTM isntance and use the first-party GTM domain if flag is set. + const src = + PCAppOverride ?? + (flags['ads-first-party-gtm'] + ? 'https://www.ft.com/page-resources/' + : 'https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68') const tagManager = `(function(w,d,s,l){ w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); diff --git a/packages/dotcom-ui-shell/src/components/Shell.tsx b/packages/dotcom-ui-shell/src/components/Shell.tsx index 91b7625bf..f8cc79968 100644 --- a/packages/dotcom-ui-shell/src/components/Shell.tsx +++ b/packages/dotcom-ui-shell/src/components/Shell.tsx @@ -60,7 +60,7 @@ function Shell(props: TShellProps) { asyncStylesheets={props.asyncStylesheets} /> - +