[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
Google Tag Manager is the JavaScript that Google Analytics use. If you use Google Analytics 4, you are using Google Tag Manager.

That being said, I'm 100% certain it's a misconfiguration with your Apache web server. If you aren't able to sort that out, you can disable the option of hosting it on your own domain and it should still work (just not from your own domain).
 
Alright, I'll try that. I tried setting up a google tag manager workspace and published it. As it's just one site I was just using the tag code. Not sure they are the same but we'll see.
 
You don't need to set up anything other than have a Google Analytics account, and you don't need to edit any templates in XenForo. Anything you are doing beyond that is outside the scope of anything you need to do for this add-on.

The only issue I see is the one where your web server isn't passing the request for the JavaScript along to XenForo. Like I said, if you aren't able to sort that out with your web server, you can simply choose to not serve the JavaScript from your own domain (then it won't matter because it's not trying to do it that way).

Anything you are adding to templates manually or the use of Google Tag Manager Workspace is nothing you need to do as far as this add-on goes. So if you are doing that, make sure you have a reason that is unrelated to this add-on for doing it (there might be a reason to do something like that if you are doing really advanced custom things, just don't do it "just because"). :)
 
I'm not well versed on linux/ubuntu as I'm primarily a Windows server guy. I'll see if I can figure anything out. Seems to be working now with the change you suggested. If you can steer me towards anything to check with apache or folder permissions I may have missed in XF please let me know.
 
Honestly, it's been so long since I've used Apache (over a decade), I'm probably not the best person to ask (switched to Nginx a long time ago). But if you are able to get your Apache config files and if you want to post them, I could probably spot it pretty quick. Like I said, I'd bet money it's setup to do something "special" if the URI being requested has the string "javascript" in it. So if you see javascript in there anywhere, you are probably in the right area of the config.
 
I don't see anything in the apache2.conf related to javascript. From the URL of the error, is there supposed to be a /javascript directory under the root of the site?

[URL]https://rvforums.com/javascript/gtm.js?_v=1f28a2e9[/URL]
 
No... /javascript/ is the XenForo route. Once the request gets passed to XenForo, XenForo handles it.

Similar to how you don't have a /threads/ directory for your site, but XenForo handles it.

You can tell the request is never getting to XenForo (which is how I know Apache is treating the request differently). If you look at the request, it's an Apache error about it not being found.


If you change just the "javascript" part of the route to "invalidroute", you see a different error... the request made it to XenForo, and XenForo doesn't have that route:


So in the case of the javascript request, Apache is not passing it along to XenForo.
 
Would it be worthwhile for you to test on an apache config? Is XF looking for JS or javascript in the route?
 
/js/ isn't a route XenForo uses, it relies on the web server to serve up static files there. XenForo routes aren't specific to Apache or Nginx, so (thankfully) it's not something you need to test for each route. But the web server does need to pass along requests to XenForo (which it normally does).

Basically I would bet a large sum of money that somewhere in your Apache config (or .htaccess file somewhere) you have a rule in there that is looking for a request with the string "javascript" in it and then doing something different. Normally you should be able to make a URL with any random old route and XenForo handles it (in the example in my previous post you can see how XenForo is handling the route when XF gives you the message saying it's not found). The fact that just for "javascript" in the URL, the web server is choosing to handle it itself and not pass the request along to XF is telling. :)
 
I welcome your help. Attached is a zip file with my apach2.conf file and also the .htaccess file in a htaccess.txt file.
 

Attachments

Like I said, it's been a long time since I've done anything with Apache, so I'm the wrong person to ask. You would be better off talking to the administrator of the server. It's not the default way that Apache works, so someone, somewhere added something that is intercepting the request and not passing it to XenForo. Whoever setup Apache on your server is going to be able to offer better insight than I can. I know it's not how Apache works by default, but it's been so long since I worked with Apache I'm useless other than being able to point you in some very general directions...
  • Check main conf file for anything related to "javascript"
  • Check virtual host conf for the same
  • Check .htaccess file(s) for the same
  • Check to make sure someone didn't create an actual "javascript" folder for your site (if Apache sees it's an actual folder, it won't pass the request along to XenForo... that's how the web server knows to NOT pass the request along to XenForo when it's an actual folder like the "js" folder). If someone did create a "javascript" folder, ask them why before you go and delete it. There's always a reason for something, and not worth breaking something else if someone did it for some reason. Like maybe some 3rd party framework installed in the same place uses that real folder for something.
  • Check your Apache error log, it might have some info/insight as well.
If you find anything, try temporarily disabling/commenting out whatever it is and see if it fixes it. Again, all I would be doing is Googling it myself because Apache isn't my thing.

At this point it's easier to just disable trying to serve it from your own domain and be done with it if you don't know why your web server is not passing the request along to XenForo and no one around you knows either. That's all this is about at this point, just being able to serve it from a cache on your own domain. Is it even worth it? 🤷🏻‍♂️
 
I own the hardware and did the install and do the admin/management, it's all me. So I'm familiar with the config and what changed out of the box on the Ubuntu 20.04 install, not much. PHP 8.1 and everything per the docs such as XF etc. It may be a conflict with another add-on, who knows. I think if "javascript" had a problem it would rear its ugly head in other places. I still believe the 404 error is a call to Google Tag Manager and not something I had setup nor did I do it right yesterday most likely but regardless, turning off the option you suggested is working. I'll explore but won't spend too much time on it. I did look at the Apache error log and didn't see anything. Only item of concern for me was something with mpm_prefork and HTTP 2.
 
Feature suggestion: Add a link in areas that take me to my Google Analytics account.

I'm browsing the nice features such as in the Admin home page, the charts area, etc. but it would be a nice to go to Google Analytics which of course I can type into my browser, etc. But if I want to go from your add-on to Google Analytics you can make it easier for me with a click.
 
I own the hardware and did the install and do the admin/management, it's all me. So I'm familiar with the config and what changed out of the box on the Ubuntu 20.04 install, not much. PHP 8.1 and everything per the docs such as XF etc. It may be a conflict with another add-on, who knows. I think if "javascript" had a problem it would rear its ugly head in other places. I still believe the 404 error is a call to Google Tag Manager and not something I had setup nor did I do it right yesterday most likely but regardless, turning off the option you suggested is working. I'll explore but won't spend too much time on it. I did look at the Apache error log and didn't see anything. Only item of concern for me was something with mpm_prefork and HTTP 2.
You aren't the first one with a web server setup to treat "javascript" differently and assume a request to that "directory" is static files. While it's not the best web server configuration to take liberties like that without it actually checking if the directory exists, it's outside the scope of what I want to do (debug people's web server configs). There's literally no reason the route needs to be named "javascript" as far as the add-on is concerned, it was simply logical since you can't use "js" because that an actual directory XenForo uses. In light of that, I changed the route from "javascript" to "jc" (Javascript cache), which will work around the web server configurations that are assuming "javascript" is an actual directory (and not passing the request along to XenForo) for the next version.

Feature suggestion: Add a link in areas that take me to my Google Analytics account.

I'm browsing the nice features such as in the Admin home page, the charts area, etc. but it would be a nice to go to Google Analytics which of course I can type into my browser, etc. But if I want to go from your add-on to Google Analytics you can make it easier for me with a click.
Done (for next version). It's also "deep-linking" into Google Analytics reports where it can (link from realtime block links to realtime report in Google Analytics, link from client-side errors report links to exceptions report in Google Analytics, etc.)
 
I've made no such configuration change. My server is as stock as it can be without any modifications needed for XF. This server runs nothing but 6 XF sites. I'm sure some day someone will figure out this issue. My belief remains is that it is because I don't have a Google Tag Manager setup. If you google the 404 error you'll see the common resolution relates to GTM.
 
I've made no such configuration change. My server is as stock as it can be without any modifications needed for XF. This server runs nothing but 6 XF sites. I'm sure some day someone will figure out this issue. My belief remains is that it is because I don't have a Google Tag Manager setup. If you google the 404 error you'll see the common resolution relates to GTM.
It's definitely not a GTM issue... it's any request to that route on your web server. The way XenForo works is it handles the route. For example there is no threads directory in the root of your XenForo install, the request is passed along to XenForo to handle how it sees fit.

An example of this is if you go here:


"random" isn't a directory on your web server and the whole request is passed along to XF. XF doesn't have that route, so it returns a 404 page not found error (but formatted by XF).

In the case of just the javascript route:


See how the error is different? It's nothing to do with tag manager, rather your web server (is choosing to not pass the request along to XenForo for whatever reason), and you end up with the generic 404 not found from the web server (not XenForo) because the request never makes it to XenForo.

Because of that (and how you can see the request never gets to XenForo like the first URL does), I would bet you any amount of money it's a web server config issue. However, I'm not trying to take your money and it's also neither here nor there at this point because I changed the route to "jc". Which your web server is passing along to XenForo (but the route doesn't exist yet because you don't have the the unreleased version installed yet):


If you look at that same route here at XenForo (or try any other random XF site), you won't see the generic web server error, rather the XF error because the request is being passed along to XenForo by the web server:

 
I'm a developer. I understand routes. I'll do some tests on my dev site and see if it's an add-on conflict. I have one that I suspect it could be.
 
If you are talking about XenForo add-ons, it’s not that. The web server isn’t passing the request along to XenForo, so there’s no point that a XenForo add-on could come into play. If it’s some Apache add-on of some sort, yes… it could be that. Like I said, the request is not leaving Apache (not being passed to XenForo by the web server).

It’s also an issue on all 3 of the sites in your signature. So whatever the common denominator is with those 3 sites is something to look at.
 
It’s also not a huge deal if you can’t get to the bottom of it. You can simply disable the option to host the JavaScript on your own domain, at which point the javascript route isn’t used for anything. Additionally, I changed the route from javascript to jc for the next version so becomes moot at that point anyway.

Personally, I’d probably try to get to the bottom of it just because I like to know why things happen (and hopefully fix it so something similar doesn’t happen in the future for some other random unrelated route). But I’m also kind of ocd. Hah
 
Top Bottom