上次的写法还是有点问题。现在修改如下:
在NUXT head 添加script 脚本
app: {
head: {
title: 'BAi Embroidery Machine',
script: [
{
src: 'https://www.googletagmanager.com/gtm.js?id=填写id',
type: 'text/javascript',
async: true,
},
{
innerHTML: `(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','填写id');`
},
{
src: 'https://www.googletagmanager.com/gtag/js?id=填写id'
},
{
innerHTML: `window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-10907661652');
`
},
]
},
link: [
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }
],
},