Better Analytics

Better Analytics 3.1.1

No permission to download
All of a sudden I'm getting Error 500 pages on my forums home page, while the threads pages are still working fine.

This is the server error in the admincp:

Code:
Server Error Log
Error Info
ErrorException: Fatal Error: Only variables can be passed by reference - library/DigitalPointBetterAnalytics/Model/Analytics.php:127
Generated By: Defkalion, 1 minute ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(28) "https://www.avsite.gr/forum/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Everything goes back to normal once I de-activate this add-on.

Any ideas on what the issue is ?
 
It's a thing with the newest version of PHP. Already fixed on my end, but haven't pushed out the update yet.

Change this:
PHP:
$currency = @end(@$data['revenue']['rows']);

To this:
PHP:
$rows = (array)@$data['revenue']['rows'];
$currency = @end($rows);
 
Many thanks Shawn - do I need to implement that in my other forums as well? Even though they 're on the same server they are not showing the errors.
 
Certainly wouldn’t hurt. Might be easy to replace that file on the other installs in case something comes up in those configs that starts causing an issue. Hard to say why or why not one would get an error over the other, but it definitely wouldn’t hurt.
 
Hi Shawn. I'm running version 3.1.3 (I don't know how - did you send it me some time?) and I've suddenly (inexplicably) started getting lots of errors:
Request State
Stack Trace
ErrorException: Undefined property: stdClass::$expires_in - library/DigitalPointBetterAnalytics/Helper/Reporting.php:105
Generated By: Unknown Account, 1 minute ago
#0 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Helper/Reporting.php(105): XenForo_Application::handlePhpError(8, 'Undefined prope...', '/home/sites/avf...', 105, Array)
#1 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Helper/Reporting.php(368): DigitalPointBetterAnalytics_Helper_Reporting::checkAccessToken()
#2 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Model/Analytics.php(205): DigitalPointBetterAnalytics_Helper_Reporting->getRealtime('rt:activeUsers', 'rt:pagePath', '-rt:activeUsers', 'rt:pagePath=~/i...')
#3 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/CronEntry/Cron.php(15): DigitalPointBetterAnalytics_Model_Analytics->getRealtimeUsage()
#4 /home/sites/avforums/public_html/library/XenForo/Model/Cron.php(356): DigitalPointBetterAnalytics_CronEntry_Cron::runVeryOften(Array)
#5 /home/sites/avforums/public_html/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#6 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(295): XenForo_Deferred_Cron->execute(Array, Array, 7.9999990463257, '')
#7 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(429): XenForo_Model_Deferred->runDeferred(Array, 7.9999990463257, '', false)
#8 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(374): XenForo_Model_Deferred->_runInternal(Array, 8, '', false)
#9 /home/sites/avforums/public_html/deferred.php(23): XenForo_Model_Deferred->run(false)
#10 {main}
/home/sites/avforums/public_html/library/Zend/Debug.php:82:
array(3) {
'url' =>
string(37) "https://www.avforums.com/deferred.php"
'_GET' =>
array(0) {
}
'_POST' =>
array(3) {
'_xfRequestUri' =>
string(74) "/threads/kef-chord-electronics-cranage-north-west-audio-show-2018.2175472/"
'_xfNoRedirect' =>
string(1) "1"
'_xfResponseType' =>
string(4) "json"
}
}

and

Stack Trace
Request State
ErrorException: Undefined property: stdClass::$token_type - library/DigitalPointBetterAnalytics/Helper/Reporting.php:104
Generated By: Unknown Account, 11 minutes ago
#0 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Helper/Reporting.php(104): XenForo_Application::handlePhpError(8, 'Undefined prope...', '/home/sites/avf...', 104, Array)
#1 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Helper/Reporting.php(368): DigitalPointBetterAnalytics_Helper_Reporting::checkAccessToken()
#2 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/Model/Analytics.php(205): DigitalPointBetterAnalytics_Helper_Reporting->getRealtime('rt:activeUsers', 'rt:pagePath', '-rt:activeUsers', 'rt:pagePath=~/i...')
#3 /home/sites/avforums/public_html/library/DigitalPointBetterAnalytics/CronEntry/Cron.php(15): DigitalPointBetterAnalytics_Model_Analytics->getRealtimeUsage()
#4 /home/sites/avforums/public_html/library/XenForo/Model/Cron.php(356): DigitalPointBetterAnalytics_CronEntry_Cron::runVeryOften(Array)
#5 /home/sites/avforums/public_html/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#6 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(295): XenForo_Deferred_Cron->execute(Array, Array, 7.9999990463257, '')
#7 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(429): XenForo_Model_Deferred->runDeferred(Array, 7.9999990463257, '', false)
#8 /home/sites/avforums/public_html/library/XenForo/Model/Deferred.php(374): XenForo_Model_Deferred->_runInternal(Array, 8, '', false)
#9 /home/sites/avforums/public_html/deferred.php(23): XenForo_Model_Deferred->run(false)
#10 {main}
/home/sites/avforums/public_html/library/Zend/Debug.php:82:
array(3) {
'url' =>
string(37) "https://www.avforums.com/deferred.php"
'_GET' =>
array(0) {
}
'_POST' =>
array(3) {
'_xfRequestUri' =>
string(82) "/threads/what-are-you-currently-listening-to-and-on-what-part-iii.1720637/page-150"
'_xfNoRedirect' =>
string(1) "1"
'_xfResponseType' =>
string(4) "json"
}
}

Any ideas?
 
Last edited:
That looks like your API settings got deleted somehow. If you relink your Google Analytics account it should put it back.
 
That looks like your API settings got deleted somehow. If you relink your Google Analytics account it should put it back.
Spot on, Shawn, thank you. That's odd. I wonder how that could have been wiped. The drop down was empty and I had to click the Link/Authenticate A Different Google Analytics Account button and log in to Google to get the AVForums GA property in the list.
Could that have been Google updating something which invalidated the AVForums info?
 
Spot on, Shawn, thank you. That's odd. I wonder how that could have been wiped. The drop down was empty and I had to click the Link/Authenticate A Different Google Analytics Account button and log in to Google to get the AVForums GA property in the list.
Could that have been Google updating something which invalidated the AVForums info?
Ya, could have been a bunch of different things. Could have been invalidated on Goggle's side (usually the user unauthorizing a linked app), could have been a database issue when the updated token was being written, etc. Definitely not a normal thing though...
Is this going to be ported to 2.1? It looks very interesting!
At some point.
 
Hi Shawn,

I want to upgrade my forum to xf2. My first step was to uninstall the addon from my test board.
After that the Better Analytics user field for Google Analytics Client ID is still there

What's the best way to remove it?
Bildschirmfoto 2020-03-15 um 13.48.36.png
Any ideas?
 
Last edited:
I have some XF2 sites... But I haven't really had the time. I have a partial version running on a site, but who knows when I'll have time to finish it and package it up. If I ever get it done, it will have many more features (more in-line with my WordPress version).

But it is started (however there's a LOT more that needs to be done, and no time frame)...

1590528953936.webp
 
I have some XF2 sites... But I haven't really had the time. I have a partial version running on a site, but who knows when I'll have time to finish it and package it up. If I ever get it done, it will have many more features (more in-line with my WordPress version).

But it is started (however there's a LOT more that needs to be done, and no time frame)...

View attachment 226045

Thanks for the update :) Good to know we have something in store for 2.x at least.
 
Spent some time this week working on the XF2 version. It's not quite ready, but it would be a good time for any feature requests.

This is what the settings currently look like. Most things are functional/working. It's going to be a GA4-only system since Universal Analytics is going away completely in about a year.

1651796704455.webp

Proxy system for serving Google Tag Manager JavaScript from your own domain is particularly nice (saves DNS queries and connection handshaking to different server). It also allows you to have control over caching of the JavaScript (normally Google forces clients to re-download the whole thing every 15 minutes). Also supports network automatic edge caching with things like Cloudflare.

The "Link Google account" allows you to use OAuth2 to connect to your Google Analytics account to do things via API. For example the "Set" button next to the measurement ID gives you a UI to pick your property and get the measurement ID for it automatically via API calls. It also allows for direct reporting within the admin area. Still some work to do on the reporting stuff for some charts and things. But here's an example of a working heat map in the XF admin, pulling data from GA via API:

1651797040671.webp

Going to add some functionality for creating new properties and new data streams via API if users want to make it easy for a new site (or a new GA4 property since they aren't backwardly compatible with Universal Analytics).
 
@digitalpoint: This looks very nice so far! :) Can't wait to play around with it.

2 feature requests:
  • Could you also add the option to track new created threads?
  • It also would be really cool, if it would be easy for other developer to extend the tracking of events for other content types. For example i'm trying for years to track comments and reviews from @Bob s AddOns (like AMS, RMS,...) in Google Analytics.
Thank you :)
 
Top Bottom