首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Netlify不会部署,我正在尝试将google标签管理器添加到gatsby站点,但遇到了困难

Netlify不会部署,我正在尝试将google标签管理器添加到gatsby站点,但遇到了困难
EN

Stack Overflow用户
提问于 2019-10-29 22:53:07
回答 1查看 351关注 0票数 0

因此,我正在尝试将the google marketing platform插件添加到一个gatsby站点,并按照说明在gatsbyconfig.js中应用它,但当我尝试部署它时,它给出了一个错误。插件代码本身看起来很好,因为没有错误,但一旦我尝试部署它,它就会显示"TypeError:{(中间值)(中间值)}不是一个函数“这是部署错误的图像:https://imgur.com/5RapNj4

如果这篇文章的格式很奇怪,很抱歉,我真的是个新手。

代码语言:javascript
复制
 plugins: [
    // Google marketing platform plugin
  {
    resolve: 'gatsby-plugin-google-marketing-platform',
    options: {
      dataLayer: {
        // Preset dataLayer values
        gaPropertyId: '[UA-148228240-1]',
      },
      tagmanager: {
        id: '[GTM-M73LFW6]',
        params: {
          // GTM URL Parameters
          // Ex: https://www.googletagmanager.com/gtm.js?id=[ID]&gtm_cookies_win=x
          gtm_cookies_win: 'x'
        }
      },
      analytics: {
        id: '[UA-148228240-1]',
      },
      optimize: {
        id: '[GTM-57N8BWZ]',
      },
      includeInDevelopment: true,
    },
  },
    /*
     * Sharp Image Processing
     */
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,

    /*
     *  Transform Markdown Files
     */
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        // CommonMark mode (default: true)
        commonmark: true,
        // Footnotes mode (default: true)
        footnotes: true,
        // Pedantic mode (default: true)
        pedantic: true,
        // GitHub Flavored Markdown mode (default: true)
        gfm: true,
        // Plugins configs
        plugins:     
          `gatsby-remark-relative-images`,

            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 1080,
              // linkImagesToOriginal: false,
              linkImagesToOriginal: true,
              tableOfContents: {
                heading: null,
                maxDepth: 2
              }
            }
          },

            resolve: 'gatsby-remark-copy-linked-files',
            options: {
              destinationDir: 'static'
            }
          }
        ],
        excerpt_separator: `<!-- end of excerpt -->`
      }
    ,

    /*
     *  Access to Filesystem
     */
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `src`,
        path: `${__dirname}/src`
      }
    },

    /*
     * Inline SVG Support
     */
    {
      resolve: `gatsby-plugin-react-svg`,
      options: {
        rule: {
          include: /\.inline\.svg$/
        }
      }
    },

    /*
     * SEO Metadata
     */
    `gatsby-plugin-react-helmet`,

    /*
     *  SASS
     */
    `gatsby-plugin-sass`,

    /*
     *  Styled Components
     */
    `gatsby-plugin-styled-components`,

    /*
     * Google Analytics
     */
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        trackingId: process.env.UA-148228240-1,
        // Puts tracking script in the head instead of the body
        head: true,
        // Setting this parameter is optional
        anonymize: true,
        // Setting this parameter is also optional
        respectDNT: true,
        // Avoids sending pageview hits from custom paths
        // exclude: ["/preview/**", "/do-not-track/me/too/"],
        // Enables Google Optimize using your container Id
        optimizeId: process.env.GATSBY_GOOGLE_OPTIMIZE_ID,
        // Any additional create only fields (optional)
        sampleRate: 5,
        siteSpeedSampleRate: 10,
        cookieDomain: 'getroute.com',
        // Setting this field to true will enables the parsing
        // of cross-domain linker parmeters used to transfer state across domains. (optional)
        allowLinker: true
      }
    },
EN

回答 1

Stack Overflow用户

发布于 2019-10-30 00:24:12

为什么不进入Netlify站点设置并将其添加到其中?

转到“后处理”下的“代码段注入”。

代码语言:javascript
复制
Site Settings > Build & Deploy > Post Processing

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58609912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档