MyBB Community Forums

Full Version: Google Analytics 4 doesn't activate
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I installed Google Analytics 4 and Google Universal Analytics and did like it says on the instructions

So I've disabled and tried to enable it again, but each time I try to activate

This page isn't working at the moment
yourdomain.com can't currently handle this request.
HTTP ERROR 500

When I reload the page it didn't activate!
Tried this 2/3 times and it doesn't work


Any suggestions or workarounds?

Thank you
Check your server logs to see what's causing the 500 error. If you're on shared hosting and don't have access to them, ask your hosting provider to check for you.
(2023-07-17, 08:38 AM)Laird Wrote: [ -> ]Check your server logs to see what's causing the 500 error. If you're on shared hosting and don't have access to them, ask your hosting provider to check for you.

Hi Laird,

after a reading quite a few tutorials on both my control panel and also on the 500 error I tried to solve it but had no real luck. However I could get the error.log registering what is going on and this is what it came out.

Can you see where the error is, because I can't (other that line 73 that sounds suspicious)

I have a small VPS that is running:
Ubuntu 18.04
NGINX with FPM/FastCGI

This is the error it shows now
Stack trace:
#0 /home/mybb/web/betaforum.mydomain.com/public_html/gate/modules/config/plugins.php(433): googleanalytics_activate()
#1 /home/mybb/web/betaforum.mydomain.com/public_html/gate/index.php(824): require('/home/mybb/web/...')
#2 {main}
  thrown in /home/mybb/web/betaforum.mydomain.com/public_html/inc/plugins/googleanalytics.php on line 73" while reading response header from upstream, client: 146.70.105.8, server: betaforum.mydomain.com, request: "GET /gate/index.php?module=config-plugins&action=activate&plugin=googleanalytics&my_post_key=f044d2dfa07cd1b7e74d08e949f0a30a HTTP/2.0", upstream: "fastcgi://unix:/run/php/betaforum.mydomain.com.sock:", host: "betaforum.mydomain.com"
2023/07/24 22:31:05 [error] 16772#16772: *132635 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function read() on null in /home/mybb/web/betaforum.mydomain.com/public_html/inc/plugins/googleanalytics.php:73


If you can help or guide me into a solution I would be very grateful
It is really bad not to have GA4 working at the moment

According to the support of my server ACP this error is a plugin error?!
The error on line 73 is because $cache hasn't been declared as a global variable in the googleanalytics_activate() function.

To fix this, add it to the global declarations on line 70, which becomes:
	global $db, $lang, $cache;

Note: I haven't tested this plugin nor investigated any other possible errors, so this might not get it fully working.
(2023-07-30, 02:44 AM)Laird Wrote: [ -> ]The error on line 73 is because $cache hasn't been declared as a global variable in the googleanalytics_activate() function.

To fix this, add it to the global declarations on line 70, which becomes:
	global $db, $lang, $cache;

Note: I haven't tested this plugin nor investigated any other possible errors, so this might not get it fully working.

I tried that, and at first it gave a MyBB error
Then I deactivated and activated again and it worked perfectly! Thanks for that.

What is the issue the Plugin Dev says you can configure in ACP but it doesn't show anywhere... and that is very weird
Is it because I had it mannually configured for UA? I really don't understand where should I put the GA-******* code
(2023-07-31, 06:11 PM)Jamie Wolf Wrote: [ -> ]What is the issue the Plugin Dev says you can configure in ACP but it doesn't show anywhere... and that is very weird
Is it because I had it mannually configured for UA? I really don't understand where should I put the GA-******* code

Sorry, I can't help you with that as I don't use this plugin and don't even use Google Analytics anymore.
Thank you Laird you were great on activating the plugin  Lightbulb



I have read the plugin instructions and one says it will have a configuration mode on ACP, I searched everything and found no such thing.
Is that also a bug on the
googleanalytics.lang.php?


Or maybe the fact that I configured it too late and still have the Google Universal analytics code on my footer is creating this error?

Thanks to anyone who can check this out for me my Php knowledge isn't my forte
Hi there,

i pushed the version 2.4 now. The bugs while activation will fixed there. Also i removed the old Google Analytics Universal settings. If you doesn't see all configuration fields on ACP bis uninstall and install the plugin again. In version 2.3 was a bug while updating the database so new fields doesn't setup.

Kind regards
-- snip --