question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gatsby-plugin-google-analytics doesn't seem to work with newer GA 4 properties

See original GitHub issue

Description

Google analytics doesn’t seem to work with new analytics property version 4 I believe https://support.google.com/analytics/answer/9310895

I also tried using gatsby-plugin-google-tagmanager on his own or using both plugin together but I couldn’t see any data sent to GA. I fall back to an old UA- property and everything works as expected. Am I missing something?

Steps to reproduce

Add the plugin following the documentation and use a new traking id that starts with G- instead of UA-

Expected result

The site should send tracking to google analytics

Actual result

Nothing happen

Environment

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 86.0.4240.198
    Safari: 14.0.1
  npmPackages:
    gatsby: ^2.26.1 => 2.26.1
    gatsby-image: ^2.5.0 => 2.5.0
    gatsby-plugin-google-analytics: ^2.5.0 => 2.5.0
    gatsby-plugin-google-fonts: ^1.0.1 => 1.0.1
    gatsby-plugin-manifest: ^2.6.0 => 2.6.0
    gatsby-plugin-offline: ^3.4.0 => 3.4.0
    gatsby-plugin-react-helmet: ^3.4.0 => 3.4.0
    gatsby-plugin-sharp: ^2.8.0 => 2.8.0
    gatsby-plugin-theme-ui: ^0.3.3 => 0.3.3
    gatsby-source-dev: ^0.1.4 => 0.1.4
    gatsby-source-devto: ^1.1.0 => 1.1.0
    gatsby-source-filesystem: ^2.5.0 => 2.5.0
    gatsby-transformer-sharp: ^2.6.0 => 2.6.0
  npmGlobalPackages:
    gatsby-cli: 2.12.66

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

28reactions
nickmccurdycommented, Dec 15, 2020

gatsby-plugin-google-analytics is only for analytics.js, which has been deprecated and isn’t supported by GA 4. Instead you’ll want to use gatsby-plugin-google-gtag which uses the newer gtag.js that supports both GA 3 and GA 4.

1reaction
ubuntutestcommented, Dec 2, 2020

yes, you can just rollback to GA 3 (Universal Analytics), I’m interested in finding a solution for GA 4

Read more comments on GitHub >

github_iconTop Results From Across the Web

GatsbyJS & GA4: Upgrading a Gatsby Site to Google Analytics 4
There were 3 primary methods for implementing Universal Analytics on a Gatsby site: 1) using the gatsby - plugin - google - analytics...
Read more >
How to Add Google Analytics 4.0 To a Gatsby Site Using Gtag
In this video, I walk through creating a new Google Analytics 4 property, installing the Gtag (global site tag) plugin on a Gatsby...
Read more >
How to Add Google Analytics 4 to a Gatsby Site ... - YouTube
In this video, I walk through creating a Google Analytics 4.0 account, installing the Google Tag Manager plugin on a Gatsby site, ...
Read more >
How to update your Gatsby Site to Google Analytics v4
1. Change the Gatsby analytics plugin · 2. Generate a Measurement tag instead of a Tracking ID · 3. Test your Gatsby site...
Read more >
How to upgrade to GA4 from Universal Analytics with ...
In the page that appears, select Get Started under I want to create a new Google Analytics 4 property. Step Five: Select Create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found