Skip to content

Commit

Permalink
indirection so to NOT add ga when dev or int
Browse files Browse the repository at this point in the history
  • Loading branch information
cmangeat committed Jan 26, 2024
1 parent 736ed9c commit d5538e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions web/src/main/webapp/xslt/base-layout-cssjs-loader.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@

<!-- Google Tag Manager -->
<xsl:template name="ga4-load-head">
<!-- Google Tag Manager -->
<xsl:choose>
<xsl:when test="$isProd">
<script>
<![CDATA[
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
Expand All @@ -324,13 +325,17 @@
})(window,document,'script','dataLayer','GTM-NBPF5L9');
]]>
</script>
<!-- End Google Tag Manager -->
</xsl:when>
</xsl:choose>
</xsl:template>

<!-- Google Tag Manager (noscript) -->
<xsl:template name="ga4-load-body">
<!-- Google Tag Manager (noscript) -->
<xsl:choose>
<xsl:when test="$isProd">
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NBPF5L9"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
4 changes: 3 additions & 1 deletion web/src/main/webapp/xslt/base-layout.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@
then substring-after($nodeName, '|')
else $nodeName"/>

<xsl:variable name="actualHtmlHeadDescription" select="if ($isProd) then $htmlHeadDescription else ''"/>

<title><xsl:value-of select="$htmlHeadTitle"/></title>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>

<meta name="description" content="{$htmlHeadDescription}"/>
<meta name="description" content="{$actualHtmlHeadDescription}"/>
<meta name="keywords" content=""/>


Expand Down
5 changes: 5 additions & 0 deletions web/src/main/webapp/xslt/common/base-variables.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,9 @@


<xsl:variable name="metadataUserFeedbackEnabled" select="$envSystem/localrating/enable = 'advanced'" />

<xsl:variable name="isDev" select="contains($env/system/site/name, '[dev]')" />
<xsl:variable name="isInt" select="contains($env/system/site/name, '[int]')" />
<xsl:variable name="isProd" select="not($isDev) and not($isInt)" />

</xsl:stylesheet>

0 comments on commit d5538e1

Please sign in to comment.