Skip to content

Commit a8d11ec

Browse files
committed
Add GTM to build.js
1 parent 4530266 commit a8d11ec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

build.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ links.forEach(({ paths, url, title, description }) => {
1010
const htmlContent = `<!DOCTYPE html>
1111
<html lang="zh-Hant">
1212
<head>
13+
<!-- Google Tag Manager -->
14+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
15+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
16+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
17+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
18+
})(window,document,'script','dataLayer','GTM-NPVBCDZ');</script>
19+
<!-- End Google Tag Manager -->
1320
<meta charset="UTF-8">
1421
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1522
<meta http-equiv="refresh" content="0; url=${url}">
@@ -23,6 +30,10 @@ links.forEach(({ paths, url, title, description }) => {
2330
<link rel="canonical" href="${url}">
2431
</head>
2532
<body>
33+
<!-- Google Tag Manager (noscript) -->
34+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NPVBCDZ"
35+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
36+
<!-- End Google Tag Manager (noscript) -->
2637
<p>正在前往 <a href="${url}">${title}</a></p>
2738
</body>
2839
</html>`;

0 commit comments

Comments
 (0)