Better Analytics

Better Analytics 3.1.1

No permission to download

digitalpoint

Well-known member
Installed the update and still not seeing the Analytics code in my source code for any pages. Sorry for the issue.
It's not supposed to be. The more important thing is if stuff is being tracked... if you go into the "Real-Time" tab in your Google Analytics reports do you see anything happening?
 

SatGuyScott

Active member
Screen Shot 2015-02-12 at 10.02.04 PM.png

Ahh YES!

I am seeing activity in there now (I was not seeing it before) In fact as I look at it it started working again after I installed the updated version. (14 minutes ago)

Thank you!
 

kontrabass

Well-known member
It may not be due to this add-on, but do you have any ideas on why a "glitch" would appear in our analytics? On Feb 9th, only a fraction of data was collected (yes our site was up and completely functional ;) ). We've had this add-on installed for at least a month, no changes made to it...

Weird.

Screenshot at Feb 12 22-39-46.png
 

digitalpoint

Well-known member
It may not be due to this add-on, but do you have any ideas on why a "glitch" would appear in our analytics? On Feb 9th, only a fraction of data was collected (yes our site was up and completely functional ;) ). We've had this add-on installed for at least a month, no changes made to it...

Weird.

View attachment 98238
I see it too on some sites... but it's not related to plug-in.

https://www.seroundtable.com/google-analytics-data-missing-19851.html

It isn't.

https://www.religiousforums.com/

<script src="misc/a.js?_v=4633b275"></script>

Not found
Looks like you have an issue with your web server where it's intercepting requests with a .js extension and doing something on it's own (I tested a few other extensions, and it looks like your web server is doing the same thing for things like .png, .css, etc.)

Maybe they are trying to cache static content behind the scenes or something, but either way, if the file doesn't exist the request should be passed through the XenForo (which isn't happening in your case).

You can see this happening because no matter what the extension, if it's a XenForo routable request, you should get an XF error if it doesn't exist...

For example, if you added "something.png" to this thread:

https://xenforo.com/community/threads/better-analytics.58746/something.png

It's a XF error (as expected).

In your case, it's a web server error... meaning the request never made it to the application (XenForo):

https://www.religiousforums.com/threads/the-emails-finally-pulled-me-back.173850/something.png

Remove the extension, and it routes to XF as expected.

https://www.religiousforums.com/threads/the-emails-finally-pulled-me-back.173850/something

Basically your web server is intercepting requests for certain extensions and not routing them.
 

Stuart Wright

Well-known member
@digitalpoint this addon is putting in two requests for /misc/a.js which does not exist on our server and is not in your installation package, so we're getting two 400 Bad Request errors.

upload_2015-2-14_10-40-41.png

This error has started since the installation of the latest update - v2 of the addon.
In library/DigitalPointBetterAnalytics/Listener/LoadClassControllerPublic/Misc.php you have
PHP:
<?php
class DigitalPointBetterAnalytics_Listener_LoadClassControllerPublic_Misc
{
    public static function loadClassListener($class, &$extend)
    {
        if (strpos(@$_SERVER['REQUEST_URI'], '/a.js'))
        {
            $extend[] = 'DigitalPointBetterAnalytics_ControllerPublic_Misc';
        }
    }
}
Is this the issue?
I see that there *is* a digitalpoint.com/misc/a.js

Edit: Also, with the addon installed, according to Google Analytics Real Time we have 5 active users on the site. With it deactivated, we have hundreds. The addon is definitely broken. I'm leaving it disabled for the moment.
 
Last edited:

Brent W

Well-known member
Getting this error now:

Code:
Server Error Log
Error Info
Zend_Exception: No entry is registered for key 'session' - library/XenForo/Application.php:1007
Generated By: Unknown Account, A moment ago
Stack Trace
#0 /home/nginx/domains/aspiescentral.com/public/library/WidgetFramework/Option.php(22): XenForo_Application::get('session')
#1 /home/nginx/domains/aspiescentral.com/public/library/WidgetFramework/Listener.php(131): WidgetFramework_Option::get('layoutEditorEna...')
#2 [internal function]: WidgetFramework_Listener::template_post_render('better_analytic...', '$(document).rea...', Array, Object(XenForo_Template_Public))
#3 /home/nginx/domains/aspiescentral.com/public/library/XenForo/CodeEvent.php(58): call_user_func_array(Array, Array)
#4 /home/nginx/domains/aspiescentral.com/public/library/XenForo/Template/Abstract.php(195): XenForo_CodeEvent::fire('template_post_r...', Array, 'better_analytic...')
#5 /home/nginx/domains/aspiescentral.com/public/library/XenForo/Template/Public.php(110): XenForo_Template_Abstract->render()
#6 /home/nginx/domains/aspiescentral.com/public/library/DigitalPointBetterAnalytics/ViewPublic/JavaScript.php(13): XenForo_Template_Public->render()
#7 /home/nginx/domains/aspiescentral.com/public/library/XenForo/ViewRenderer/Abstract.php(227): DigitalPointBetterAnalytics_ViewPublic_JavaScript->renderHtml()
#8 /home/nginx/domains/aspiescentral.com/public/library/XenForo/ViewRenderer/HtmlPublic.php(71): XenForo_ViewRenderer_Abstract->renderViewObject('DigitalPointBet...', 'Html', Array, 'better_analytic...')
#9 /home/nginx/domains/aspiescentral.com/public/library/XenForo/FrontController.php(586): XenForo_ViewRenderer_HtmlPublic->renderView('DigitalPointBet...', Array, 'better_analytic...', NULL)
#10 /home/nginx/domains/aspiescentral.com/public/library/XenForo/FrontController.php(158): XenForo_FrontController->renderView(Object(XenForo_ControllerResponse_View), Object(XenForo_ViewRenderer_HtmlPublic), Array)
#11 /home/nginx/domains/aspiescentral.com/public/index.php(13): XenForo_FrontController->run()
#12 {main}
Request State
array(3) {
  ["url"] => string(51) "https://www.aspiescentral.com/misc/a.js?_v=c15df8d1"
  ["_GET"] => array(2) {
    ["/misc/a_js"] => string(0) ""
    ["_v"] => string(8) "c15df8d1"
  }
  ["_POST"] => array(0) {
  }
}
 

digitalpoint

Well-known member
@digitalpoint this addon is putting in two requests for /misc/a.js which does not exist on our server and is not in your installation package, so we're getting two 400 Bad Request errors.

View attachment 98344

This error has started since the installation of the latest update - v2 of the addon.
In library/DigitalPointBetterAnalytics/Listener/LoadClassControllerPublic/Misc.php you have
PHP:
<?php
class DigitalPointBetterAnalytics_Listener_LoadClassControllerPublic_Misc
{
    public static function loadClassListener($class, &$extend)
    {
        if (strpos(@$_SERVER['REQUEST_URI'], '/a.js'))
        {
            $extend[] = 'DigitalPointBetterAnalytics_ControllerPublic_Misc';
        }
    }
}
Is this the issue?
I see that there *is* a digitalpoint.com/misc/a.js

Edit: Also, with the addon installed, according to Google Analytics Real Time we have 5 active users on the site. With it deactivated, we have hundreds. The addon is definitely broken. I'm leaving it disabled for the moment.
The short answer is it's a server configuration issue... Same issue as here: https://xenforo.com/community/threads/better-analytics.58746/page-13#post-897490

Basically your web server is intercepting HTTP requests with certain extensions and not passing the request through (which is why if you go to the URL, you get an error from the web server, not an error from XenForo... it's not passing through the request.

You can see the different error here: Raw web server error (not passing the request through to the application):

https://www.avforums.com/misc/a.js

The same URL but different extension:

https://www.avforums.com/misc/a.txt

Different looking error page (meaning the request is getting to the application).

Probably some caching mechanism on the server that is basing itself on file extensions in the HTTP request, rather than if a file actually exists.

I'd say it's a server misconfiguration there, but if you don't want to fix it, you probably could work around it by editing the PAGE_CONTAINER template modification for Better Analytics, and change this:
Code:
<script src="misc/a.js?_v={$xenOptions.jsVersion}">
to this:
Code:
<script src="misc/a?_v={$xenOptions.jsVersion}">

and in the DigitalPointBetterAnalytics_Listener_LoadClassControllerPublic_Misc class, change this:
PHP:
if (strpos(@$_SERVER['REQUEST_URI'], '/a.js'))
to this:
PHP:
if (substr(@$_SERVER['DOCUMENT_URI'], -2) == '/a')

That would probably work around it, but ultimately it's a web server (or maybe front-end proxy of some sort) config issue on your end where the web server is intercepting HTTP requests based on the file extension even if that file doesn't exist on your web server.



Getting this error now:

Code:
Server Error Log
Error Info
Zend_Exception: No entry is registered for key 'session' - library/XenForo/Application.php:1007
Generated By: Unknown Account, A moment ago
Stack Trace
#0 /home/nginx/domains/aspiescentral.com/public/library/WidgetFramework/Option.php(22): XenForo_Application::get('session')
#1 /home/nginx/domains/aspiescentral.com/public/library/WidgetFramework/Listener.php(131): WidgetFramework_Option::get('layoutEditorEna...')
#2 [internal function]: WidgetFramework_Listener::template_post_render('better_analytic...', '$(document).rea...', Array, Object(XenForo_Template_Public))
#3 /home/nginx/domains/aspiescentral.com/public/library/XenForo/CodeEvent.php(58): call_user_func_array(Array, Array)
#4 /home/nginx/domains/aspiescentral.com/public/library/XenForo/Template/Abstract.php(195): XenForo_CodeEvent::fire('template_post_r...', Array, 'better_analytic...')
#5 /home/nginx/domains/aspiescentral.com/public/library/XenForo/Template/Public.php(110): XenForo_Template_Abstract->render()
#6 /home/nginx/domains/aspiescentral.com/public/library/DigitalPointBetterAnalytics/ViewPublic/JavaScript.php(13): XenForo_Template_Public->render()
#7 /home/nginx/domains/aspiescentral.com/public/library/XenForo/ViewRenderer/Abstract.php(227): DigitalPointBetterAnalytics_ViewPublic_JavaScript->renderHtml()
#8 /home/nginx/domains/aspiescentral.com/public/library/XenForo/ViewRenderer/HtmlPublic.php(71): XenForo_ViewRenderer_Abstract->renderViewObject('DigitalPointBet...', 'Html', Array, 'better_analytic...')
#9 /home/nginx/domains/aspiescentral.com/public/library/XenForo/FrontController.php(586): XenForo_ViewRenderer_HtmlPublic->renderView('DigitalPointBet...', Array, 'better_analytic...', NULL)
#10 /home/nginx/domains/aspiescentral.com/public/library/XenForo/FrontController.php(158): XenForo_FrontController->renderView(Object(XenForo_ControllerResponse_View), Object(XenForo_ViewRenderer_HtmlPublic), Array)
#11 /home/nginx/domains/aspiescentral.com/public/index.php(13): XenForo_FrontController->run()
#12 {main}
Request State
array(3) {
  ["url"] => string(51) "https://www.aspiescentral.com/misc/a.js?_v=c15df8d1"
  ["_GET"] => array(2) {
    ["/misc/a_js"] => string(0) ""
    ["_v"] => string(8) "c15df8d1"
  }
  ["_POST"] => array(0) {
  }
}
Looks like the WidgetFramework is assuming a user session is going to be available 100% of the time, which isn't always the case. They should be using the isRegistered function in XenForo before trying to get the session.

Something more like:
PHP:
if (XenForo_Application::isRegistered('session')) {
    XenForo_Application::get('session'); // existing code
}

The session isn't guaranteed to be available (which is why there is a XF method to check if it's registered/available), they just don't seem to be using it.
 

digitalpoint

Well-known member
@digitalpoint Shawn, Tim at Nimbus tells me it's because we have minify running on NGINX

The nginx code rewrites that url to here.

Code:
       location ~* ^.+\.(css|js|php)$ {
               rewrite ^(.*) /min/index.php?f=$1 last;
               expires max;
       }

I.e. this code rewrites it to https://www.avforums.com/min/index.php?f=misc/a.js
You really should only be intercepting the HTTP request if the file you think you are intercepting actually exists in the file system...

Something more like this...
Code:
location ~* ^.+\.(css|js|php)$ {
    if (-f $request_filename) {
        break;
    }
    rewrite ^(.*) /min/index.php?f=$1 last;
    expires max;
}

There really can be nothing good if you are trying to minify files that don't exist. :)
 

Mouth

Well-known member
@digitalpoint this addon is putting in two requests for /misc/a.js which does not exist on our server and is not in your installation package, so we're getting two 400 Bad Request errors.
I'm the same.
No /misc/a.js file on my site, and it's not in the add-on install package.
All Google Analytics metrics have completely stopped since upgrading to v2.0.0 (and v2.0.0a to be sure) a few days ago.

Screen Shot 2015-02-16 at 23.58.08.png
 

Stuart Wright

Well-known member
You really should only be intercepting the HTTP request if the file you think you are intercepting actually exists in the file system...

Something more like this...
Code:
location ~* ^.+\.(css|js|php)$ {
    if (-f $request_filename) {
        break;
    }
    rewrite ^(.*) /min/index.php?f=$1 last;
    expires max;
}

There really can be nothing good if you are trying to minify files that don't exist. :)
Thanks Shawn. Would you recommend using minify?
 

DRaver

Active member
After installing nothing is tracked. Also no analytics code is found in the source code of the webpage.
 

XxUnkn0wnxX

Active member
ever since i updated this has been driving me nuts in the logs:
@digitalpoint
Code:
Zend_Exception: No entry is registered for key 'session' - library/XenForo/Application.php:1007
Generated By: Unknown Account, A moment ago
Stack Trace
#0 /home/unkn0wn/public_html/forums/library/XenForo/Application.php(1587): XenForo_Application::get('session')
#1 /home/unkn0wn/public_html/forums/library/Sedo/TinyQuattro/Listener/AllInOne.php(28): XenForo_Application::getSession()
#2 [internal function]: Sedo_TinyQuattro_Listener_AllInOne::controllerPreDispatch(Object(DigitalPointBetterAnalytics_ControllerPublic_Misc), 'A', 'XenForo_Control...')
#3 /home/unkn0wn/public_html/forums/library/XenForo/CodeEvent.php(58): call_user_func_array(Array, Array)
#4 /home/unkn0wn/public_html/forums/library/XenForo/Controller.php(311): XenForo_CodeEvent::fire('controller_pre_...', Array, 'XenForo_Control...')
#5 /home/unkn0wn/public_html/forums/library/XenForo/FrontController.php(346): XenForo_Controller->preDispatch('A', 'XenForo_Control...')
#6 /home/unkn0wn/public_html/forums/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#7 /home/unkn0wn/public_html/forums/index.php(13): XenForo_FrontController->run()
#8 {main}
Request State
array(3) {
  ["url"] => string(57) "http://www.portalcentric.net/forums/misc/a.js?_v=7ba32738"
  ["_GET"] => array(1) {
    ["_v"] => string(8) "7ba32738"
  }
  ["_POST"] => array(0) {
  }
}
 
Last edited:

XxUnkn0wnxX

Active member
@cclaerhout

i also get this with the above log:

Code:
Server Error

No entry is registered for key 'session'

XenForo_Application::get() in XenForo/Application.php at line 1587
XenForo_Application::getSession() in Sedo/TinyQuattro/Listener/AllInOne.php at line 28
Sedo_TinyQuattro_Listener_AllInOne::controllerPreDispatch()
call_user_func_array() in XenForo/CodeEvent.php at line 58
XenForo_CodeEvent::fire() in XenForo/Controller.php at line 311
XenForo_Controller->preDispatch() in XenForo/FrontController.php at line 346
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in /home/unkn0wn/public_html/forums/index.php at line 13

since i applied: https://xenforo.com/community/threads/better-analytics.58746/page-13#post-897921

no longer getting annoying messages in log...

but i'm not using nginix.. although i am using strict htaccess and mod security rules to protect against malicious attacks and exploits.

i asume i would have to apply this work around each time this add one updates?
 
Last edited:

cclaerhout

Well-known member
@cclaerhout

i also get this with the above log:

Code:
Server Error

No entry is registered for key 'session'

XenForo_Application::get() in XenForo/Application.php at line 1587
XenForo_Application::getSession() in Sedo/TinyQuattro/Listener/AllInOne.php at line 28
Sedo_TinyQuattro_Listener_AllInOne::controllerPreDispatch()
call_user_func_array() in XenForo/CodeEvent.php at line 58
XenForo_CodeEvent::fire() in XenForo/Controller.php at line 311
XenForo_Controller->preDispatch() in XenForo/FrontController.php at line 346
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in /home/unkn0wn/public_html/forums/index.php at line 13

since i applied: https://xenforo.com/community/threads/better-analytics.58746/page-13#post-897921

no longer getting annoying messages in log...

but i'm not using nginix.. although i am using strict htaccess and mod security rules to protect against malicious attacks and exploits.

i asume i would have to apply this work around each time this add one updates?

I've already replied about this topic with a possible and working solution in this post. Checking if the session is registered will have no effect. I haven't got any reply since, so I'm done with it.
 

digitalpoint

Well-known member
I'm the same.
No /misc/a.js file on my site, and it's not in the add-on install package.
All Google Analytics metrics have completely stopped since upgrading to v2.0.0 (and v2.0.0a to be sure) a few days ago.

View attachment 98476
I would assume the same issues as others where your web server is intercepting requests for .js files without checking if they are there.

Thanks Shawn. Would you recommend using minify?
Personally, I think it's better to minify it before going to production, so doing it on the fly just adds overhead if you are being lazy and not minifying it beforehand.

After installing nothing is tracked. Also no analytics code is found in the source code of the webpage.
Probably same issue where your web server is intercepting requests for .js files without checking if they are there.

ever since i updated this has been driving me nuts in the logs:
@digitalpoint
Code:
Zend_Exception: No entry is registered for key 'session' - library/XenForo/Application.php:1007
Generated By: Unknown Account, A moment ago
Stack Trace
#0 /home/unkn0wn/public_html/forums/library/XenForo/Application.php(1587): XenForo_Application::get('session')
#1 /home/unkn0wn/public_html/forums/library/Sedo/TinyQuattro/Listener/AllInOne.php(28): XenForo_Application::getSession()
#2 [internal function]: Sedo_TinyQuattro_Listener_AllInOne::controllerPreDispatch(Object(DigitalPointBetterAnalytics_ControllerPublic_Misc), 'A', 'XenForo_Control...')
#3 /home/unkn0wn/public_html/forums/library/XenForo/CodeEvent.php(58): call_user_func_array(Array, Array)
#4 /home/unkn0wn/public_html/forums/library/XenForo/Controller.php(311): XenForo_CodeEvent::fire('controller_pre_...', Array, 'XenForo_Control...')
#5 /home/unkn0wn/public_html/forums/library/XenForo/FrontController.php(346): XenForo_Controller->preDispatch('A', 'XenForo_Control...')
#6 /home/unkn0wn/public_html/forums/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#7 /home/unkn0wn/public_html/forums/index.php(13): XenForo_FrontController->run()
#8 {main}
Request State
array(3) {
  ["url"] => string(57) "http://www.portalcentric.net/forums/misc/a.js?_v=7ba32738"
  ["_GET"] => array(1) {
    ["_v"] => string(8) "7ba32738"
  }
  ["_POST"] => array(0) {
  }
}
Unfortunately not a lot I can do about other addons that are trying to do stuff with the session object when it's not something that is guaranteed to be there. Basically whatever that addon is is assuming sessions are available without first checking if they are.

I've already replied about this topic with a possible and working solution in this post. Checking if the session is registered will have no effect. I haven't got any reply since, so I'm done with it.
Not sure what you mean... checking if the session is available before an addon tries to do something with the session (which may not be available) would have certainly have an affect.
 
Top