Hey,
I recently moved my site into a folder within /root and used 301 redirects. Now, it seems impossible to get google analytics working,
I read up on https://www.simoahava.com/gtm-tips/chrome-samesite-warnings-google-tag-manager/
because my site is spammed with sameSite warnings and I'm not sure if it related.
Is there anything special that needs to be done with gatsby-plugin-google-analytics when used within a sub directory?
this is the site in question - https://www.craftmc.net/wiki/
and all pages under /wiki/ have the plugin injecting my google analytics code.
Any info on this is appreciated, i've tried making new properties but it just seems like google isn't tracking any page loads.
It seems my plugin isn't injecting the code into the header tag? anything I can do to debug that?
as per Roshan's response,
https://support.google.com/analytics/thread/28219902?hl=en
EDIT**
just found https://github.com/gatsbyjs/gatsby/issues/2894
I moved it into headers, still no luck, apparently this could be the issue https://support.google.com/tagassistant/answer/3059154#http_response
but not sure why the gatsby plugin would not work
@Cobwebster The gatsby-plugin-google-analytics plugin has a head option which when set to true will set the script in the sit's head.
Can you confirm that you're running the latest version? Which is 2.1.35
All the plugin does is sets the tag so this is likely unrelated to the plugin
@Cobwebster The
gatsby-plugin-google-analyticsplugin has aheadoption which when set totruewill set the script in the sit's head.Can you confirm that you're running the latest version? Which is
2.1.35All the plugin does is sets the tag so this is likely unrelated to the plugin
Yep, I have the head option and latest version :/
I seem to have this issue,
google analytics no http response detected
which seems to have generated a few gatsby plugin error posts in the past but I don't see any solutions put forward:/
I was getting the same error as you are.
As your site is now in a subdir, maybe try adding the pathPrefix value to gatsby-config.js
https://www.gatsbyjs.org/docs/path-prefix/
then compiling with:
gatsby build --prefix-paths
instead of
gatsby build
Keep in mind though:
In addition, links to various resources (JavaScript, CSS, images, and other static content) need the same prefix, so that the site continues to function correctly when served with the path prefix in place.
It fixed the issue for me
I was getting the same error as you are.
As your site is now in a subdir, maybe try adding the pathPrefix value to gatsby-config.js
https://www.gatsbyjs.org/docs/path-prefix/then compiling with:
gatsby build --prefix-paths
instead of
gatsby buildKeep in mind though:
In addition, links to various resources (JavaScript, CSS, images, and other static content) need the same prefix, so that the site continues to function correctly when served with the path prefix in place.
It fixed the issue for me
Hey, thanks for the suggestion,
I added pathPrefix: /wiki and ran the --prefix-paths cmd, no such luck though. GA still doesn't track.
Bummer :-/
Quick afterthought, I noticed you are using a different tracking id for the wiki pages.
Have you entered the website url in the GA Property Settings and View Settings as https://www.craftmc.net/wiki
as opposed than https://www.craftmc.net
Also eta.. if tracking is restricted to a subdirectory for that GA Property then cookie path should be set in the tracking code options
// cookiePath must be set when create is called.
ga('create', 'UA-XXXX-Y', 'auto', {'cookiePath': '/tracked-dir/'});
ref: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#cookiepath
Bummer :-/
Quick afterthought, I noticed you are using a different tracking id for the wiki pages.
Have you entered the website url in the GA Property Settings and View Settings as https://www.craftmc.net/wiki
as opposed than https://www.craftmc.netAlso eta.. if tracking is restricted to a subdirectory for that GA Property then cookie path should be set in the tracking code options
// cookiePath must be set when create is called.
ga('create', 'UA-XXXX-Y', 'auto', {'cookiePath': '/tracked-dir/'});
ref: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#cookiepath
I went back to my original tracking ID to make it more simple, I have now managed to resolve the issue with thanks to your support.
It seems that I should of actually made sure my site renders in a way which makes /wiki instead of just making a folder and dropping it in, I also have some mapping files in my root directory which I assume is where GA gets the links from.
Thanks again for your time and everyone else who helped out.