Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make another responsibility more explicit in the analytics shared com…
…ponent #3329
- Loading branch information
1 parent
f4c224f
commit c4d41e0
Showing
3 changed files
with
22 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/read-side/html-pages/shared-components/analytics/google-tag-manager-no-script.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as O from 'fp-ts/Option'; | ||
import { constant, pipe } from 'fp-ts/function'; | ||
import { HtmlFragment, toHtmlFragment } from '../../../../types/html-fragment'; | ||
|
||
const renderTagManagerNoScript = (tagManagerId: string) => ` | ||
<!-- Google Tag Manager (noscript) --> | ||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${tagManagerId}" | ||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
<!-- End Google Tag Manager (noscript) --> | ||
`; | ||
|
||
export const googleTagManagerNoScript = (): HtmlFragment => pipe( | ||
process.env.GOOGLE_TAG_MANAGER_ID, | ||
O.fromNullable, | ||
O.match( | ||
constant(''), | ||
renderTagManagerNoScript, | ||
), | ||
toHtmlFragment, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { googleTagManager, googleTagManagerNoScript } from './analytics'; | ||
export { fathom } from './fathom'; | ||
export { googleTagManager } from './analytics'; | ||
export { googleTagManagerNoScript } from './google-tag-manager-no-script'; |
c4d41e0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relates to ticket #3229 (not 3329 as mentioned in the commit message).