Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-plugin-google-analytics - sameSite "deadline"? #21228

Closed
Cobwebster opened this issue Feb 6, 2020 · 8 comments
Closed

gatsby-plugin-google-analytics - sameSite "deadline"? #21228

Cobwebster opened this issue Feb 6, 2020 · 8 comments
Assignees
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@Cobwebster
Copy link

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.

@gatsbot gatsbot bot added the type: question or discussion Issue discussing or asking a question about Gatsby label Feb 6, 2020
@Cobwebster
Copy link
Author

Cobwebster commented Feb 10, 2020

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 #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

@sidharthachatterjee
Copy link
Contributor

@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

@wardpeet wardpeet self-assigned this Feb 12, 2020
@Cobwebster
Copy link
Author

@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

Yep, I have the head option and latest version :/

@Cobwebster
Copy link
Author

Cobwebster commented Feb 15, 2020

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:/

@bronwynv
Copy link

bronwynv commented Feb 16, 2020

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

@Cobwebster
Copy link
Author

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

Hey, thanks for the suggestion,

I added pathPrefix: /wiki and ran the --prefix-paths cmd, no such luck though. GA still doesn't track.

@bronwynv
Copy link

bronwynv commented Feb 16, 2020

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

@Cobwebster
Copy link
Author

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants