按照谷歌的指示,在index.html中添加了标题部分的gtag。但是,我得到了一个错误。
<!doctype html>
<html lang="en">
<head>
<base href="/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hello</title>
<!-- Favicon -->
<link href="./assets/img/favicon.ico" rel="icon" type="image/png">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<!-- 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', 'GTM-01jd9k');</script>
<!-- End Google Tag Manager -->
</head>
<body>
<app-root></app-root>
</body>
</html>看着控制台,
(索引):30得到https://www.googletagmanager.com/gtm.js?id=GT....。net::ERR_ABORTED 404
看来insertBefore()是认不出来的。
Failed to load resource: the server responded with a status of 404 ()

如何在index.html中识别gtag?任何帮助都是非常感谢的!
发布于 2021-02-26 04:18:55
为google管理器使用角-google标签管理器 npm包。我用过了。这是一个很棒的包。
https://stackoverflow.com/questions/66378978
复制相似问题