Marlon Nunez
Marlon Nunez

Reputation: 1

Netlify won't deploy, I am trying to add google tag manager to a gatsby site but having difficulty

So I am trying to add the google marketing platform plugin to a gatsby site and have followed the instructions to apply it in gatsbyconfig.js but when I try and deploy it gives an error. The plugin code itself seems fine since there's no errors but once i try to deploy it displays "TypeError: {(intermediate value)(intermediate value)} is not a function" here's an image of the deploy error: https://i.sstatic.net/GLKsS.jpg.

Sorry if this was formatted oddly, I'm really new at this.

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

Upvotes: 0

Views: 694

Answers (1)

brooksrelyt
brooksrelyt

Reputation: 4025

Why not go into the Netlify site settings and add it there?

Go to snippet injection under post processing.

Site Settings > Build & Deploy > Post Processing

enter image description here

Upvotes: 1

Related Questions