Hi,
I have this weird issue.
I use the latest Google Analytics 4 Javascript code, I want to add this to my WordPress site.
In GeneratePress I add a new hook element, enter my Google Analytics code there which looks like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX<script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXX');
</script>
hook location: wp_head
priority: 1
display rules: entire site
Then I save and publish this hook element.
I can see that WordPress now adds my Google Analytics code into the head element in the HTML code, and it works, I see the analytics data in my Google Analytics account.
Now here comes my problem: if I login as administrator then I perform regular tasks such as opening posts, editing posts, uploading files, then after a few clicks suddenly I cannot access my site anymore. It just keeps loading and loading… Nothing happens.
I can only access my site again if I delete the Google analytics cookies from my browser, or if I visit in incognito mode.
Very strange. I verified and indeed these two Google Analytics cookies are the cause of this problem. Every time I delete the GA cookies, I can access my site again.
But I cannot use my site this way. The only solution right now is to disable that Google Analytics hook. But then I cannot collect the analytics data.
I tried to disable all other plugins, for example my caching plugin, but it didn’t help.
Is it an issue with GeneratePress or with Google Analytics?
I use the latest Chromium browser, and the latest version of WordPress and GeneratePress.