gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

gatsby-plugin-google-gtag only tracks activity on base / #20759

Closed jpmonette closed 4 years ago

jpmonette commented 4 years ago

Description

I have gatsby-plugin-google-gtag setup and it seems like the only page being tracked by Google Analytics is / (or events using window.gtag()) - visits to any other pages are not tracked.

Steps to reproduce

Here's my gatsby-config.js (with gatsby-plugin-google-gtag in first):

/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.org/docs/gatsby-config/
 */
module.exports = {
  siteMetadata: {
    title: `website`
  },
  mapping: {
    "MarkdownRemark.frontmatter.company": `CompaniesYaml`,
  },
  plugins: [
    {
      resolve: `gatsby-plugin-google-gtag`,
      options: {
        trackingIds: [
          "GA-UA-156321092-1", // Google Analytics / GA
        ],
        pluginConfig: {
          // Puts tracking script in the head instead of the body
          head: false,
          // Setting this parameter is also optional
          respectDNT: false,
        },
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `jobs`,
        path: `${__dirname}/content/jobs`,
      },
    },
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "mappings",
        path: `${__dirname}/content/mappings/`,
      },
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `webiste`,
        short_name: `website`,
        start_url: `/`,
        background_color: `#edc6c5`,
        icon: `static/pwa-512x512.png`,
        theme_color: `#D83B35`,
        display: `standalone`,
      },
    },
    `gatsby-plugin-robots-txt`,
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-remark`,
    `gatsby-plugin-typescript`,
    `gatsby-plugin-netlify-cms`,
    `gatsby-transformer-yaml`,
    `gatsby-plugin-sitemap`,
    "gatsby-plugin-preact",
    `gatsby-plugin-remove-trailing-slashes`,
    "gatsby-plugin-offline",
  ],
};

I am also using 1.1.21 and the website is served on Netlify.

Expected result

Visits to pages like /companies, /about... to be tracked.

Actual result

When I crawl through my Website, only visits to / are tracked.

Environment

  System:
    OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Shell: 5.6.2 - /usr/local/bin/zsh
  Binaries:
    Node: 13.1.0 - ~/.nvm/versions/node/v13.1.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v13.1.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 79.0.3945.130
    Firefox: 72.0.1
    Safari: 13.0.4
  npmPackages:
    gatsby: ^2.18.12 => 2.18.12
    gatsby-plugin-google-analytics: ^2.1.33 => 2.1.33
    gatsby-plugin-google-gtag: ^1.1.21 => 1.1.21
    gatsby-plugin-manifest: ^2.2.37 => 2.2.37
    gatsby-plugin-netlify-cms: ^4.1.33 => 4.1.33
    gatsby-plugin-offline: ^3.0.32 => 3.0.32
    gatsby-plugin-preact: ^3.1.25 => 3.1.25
    gatsby-plugin-react-helmet: ^3.1.21 => 3.1.21
    gatsby-plugin-remove-trailing-slashes: ^2.1.20 => 2.1.20
    gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0
    gatsby-plugin-sitemap: ^2.2.24 => 2.2.24
    gatsby-plugin-typescript: ^2.1.23 => 2.1.23
    gatsby-source-filesystem: ^2.1.43 => 2.1.43
    gatsby-transformer-remark: ^2.6.45 => 2.6.45
    gatsby-transformer-yaml: ^2.2.20 => 2.2.20

Thanks

vladar commented 4 years ago

Hi @jpmonette !

This sounds strange. But it is really hard to help without some code to look at. It is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

Thanks for using Gatsby! 💜

github-actions[bot] commented 4 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 4 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜