flpvsk / gatsby-plugin-gtag

Gatsby plugin to add Google Analytics gtag.js (replacement for analytics.js) to a site.
MIT License
28 stars 12 forks source link

Page Views are not sent to google analytics. #27

Closed holtzy closed 3 years ago

holtzy commented 3 years ago

Thanks for your work on this plugin.

I've managed to make it work on my website https://www.python-graph-gallery.com. I can see real time users.

However, page views are not sent at all. I believe it is because of this line of code: https://github.com/flpvsk/gatsby-plugin-gtag/blob/master/src/gatsby-ssr.js#L34

It set the send_page_view option to false. I don't understand this decision? Page views are what most people want to track through google analytics. Would it be possible to set it as an option in the plugin, or correct it?

Thanks a bunch,

Yan

flpvsk commented 3 years ago

Hey Yan, the send_page_view: false is there to avoid duplicating page views. Views are tracked here:

https://github.com/flpvsk/gatsby-plugin-gtag/blob/master/src/gatsby-browser.js#L22

Could you check your network tab? Also keep in mind that the script only works when NODE_ENV=production

holtzy commented 3 years ago

Oh all good. This line just look weird in my console, and it looks like page view took a while to be accessible on my website. All ghood now, thanks for your work! 🙏