Netlify无法部署,我正在尝试将Google跟踪代码管理器添加到gatsby网站,但遇到困难

时间:2019-10-29 14:53:06

标签: reactjs gatsby

所以我要添加the google marketing platform gatsby站点的插件,并已按照说明在gatsbyconfig.js中应用了该插件,但是当我尝试部署它时却出现了错误。插件代码本身看起来不错,因为没有错误,但是一旦我尝试部署,它就会显示“ TypeError:{(intermediate value)(intermediate value)}不是函数” 这是部署错误的图像:https://imgur.com/5RapNj4

很抱歉,如果格式化格式不正确,我真的很陌生。

 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
      }
    },

1 个答案:

答案 0 :(得分:0)

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

在后期处理下转到代码段注入。

Site Settings > Build & Deploy > Post Processing

enter image description here