[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
digitalpoint updated [DigitalPoint] Better Google Analytics with a new update entry:

Fix for email tracking and a few other minor things

  • Fixed issue where an old installation of legacy (XF1) version of add-on would cause installation issues of this (XF2) version of add-on.
  • Fixed issue where some email sent/email read events wouldn't get logged if you are tracking events by user ID.
  • Added missing phrases for "city" and "region".
  • Added ability to debug events going through backend measurement protocol.
  • Using new Google Analytics Admin API endpoint (going from v1alpha to v1beta).

Read the rest of this update entry...
 
Hi, would it be possible to extend the admin chart view to show purchases with the correspending value?

The reason is that I offer on every page the possibility to buy something, which is used quite frequently. This is tracked by my own GA4 code (a purchase event) and the data is stored in GA4.

It would be great if I could view that data as a dimension in the admin view of your addon.
 
It's a little tricky because itemRevenue is a metric, not a dimension, however there is a way that I think I can get it work.

The problem is that I don't have any property to test the reporting against to see if it would work or not. So there's a couple options here to test/see if it could work. I could do a conversation with you where I can tell you things to change/check and you tell me what the results are (would be some back and forth). The other option, would be you could grant me temporary read-only access to a GA4 property you have that has the revenue events in it and I can do reporting testing against that property.
 
Nice addon and nice to share it for free. :)

A question - is there a way that the member (guest or registered) can allow/disallow the GA4 cookie/tracking by self? We life in the EU/Germany and have at this point a strong law I think. ;-)
 
Nice addon and nice to share it for free. :)

A question - is there a way that the member (guest or registered) can allow/disallow the GA4 cookie/tracking by self? We life in the EU/Germany and have at this point a strong law I think. ;-)
There isn't a separate GDPR tracking consent popup for Google Analytics if that's what you are asking.

I'm not sure that would matter anyway because some of the European court's issue with Google Analytics is distilled down to one thing... that user data is transmitted outside of Europe (Google servers in the USA for example) even if there was no personally identifiable information in the payload being transmitted.

There are a couple things you can do to try and cover yourself in the "grey area" of what personally identifiable information is though. For example you can disable the usage of Google Signals for the Google Analytics 4 property. There's some pretty good info here:


Google Analytics 4 is trying to be GDPR compliant out of the box (like it doesn't store IP addresses, you can set data retention to very short periods (like it only keeping 2 months of data history), etc. But GDPR has a lot of grey areas from country to country and if you really want to try and be 100% compliant with everything (even outside of Google Analytics, you probably need to hire a lawyer to give real advice).

If you want to go down the road is building something that explicitly asks users for consent to be tracked with Google Analytics, it probably wouldn't be that hard to build (it could be something that just adds/removes users from a user group that uses the user group option for not tracking this user with Google Analytics). But it's not a function that is built-in by default.
 
I've been looking more into Google Analytics 4 and GDPR stuff and it looks like (maybe) Google addressed the issue about sending IP addresses to US-based servers that came up in the court rulings.

Some info here: https://support.google.com/analytics/answer/12017362

EU data is collected in the EU​

Google Analytics 4 collects all data from EU-based devices (based on IP-geo lookup) through domains and on servers based in the EU before forwarding traffic to Analytics servers for processing.

Additionally, Google Analytics 4 lets you get granular (on a per country basis) with location and device data collection.

1658766225550.webp
While it's not always going to per perfect (like a new country-specific court ruling about privacy related to Google Analytics can pop up at any time), I do feel like Google is doing their best to keep up to date with all the privacy laws and making changes as necessary. I'm sure Google is aware that if they don't, sites will stop using Google Analytics, rather than expect sites to code custom things on their side to try and stay compliant with local laws.

Personally, I think the best thing to do would be to first figure out what part of Google Analytics isn't adhering to local privacy laws and address that specifically, rather than make a consent screen for users to allow them to opt-in to non-compliant tracking (fix it at the core imo).
 
@digitalpoint Shawn, what did I do wrong?

No idea where the G-42... property ID comes from when I link the AVForums account.
How do I set this up properly please?
So first of all, a couple things to do/check...

Ignore the Google Analytics web property ID on the SEO options page. That's the setting built into XenForo, and XenForo doesn't have a realistic way for an add-on to remove options, so it's just left (and unused). The measurement ID on the Analytics options page (where you link your Google account) is the one used.

As far as where that G-42xxxxx measurement ID is coming from, it has to be coming from somewhere (it doesn't just make them up randomly). In your Google Analytics account, go to Admin -> Data Streams -> [click on your stream for the property], then you should be able to see the Measurement ID associated with that stream. If the Measurement ID isn't matching up to any property you have on your Google Account, the only thing I can think of is double-check that the right Google Account is the one you linked (could also try linking your Google Account again to make absolutely certain it's the right Google Account). I've definitely seen stranger things than someone linking the wrong Google Account and then wondering where that property is in the normal Google Analytics interface (when looking via a different Google Analytics account).
 
So first of all, a couple things to do/check...

Ignore the Google Analytics web property ID on the SEO options page. That's the setting built into XenForo, and XenForo doesn't have a realistic way for an add-on to remove options, so it's just left (and unused). The measurement ID on the Analytics options page (where you link your Google account) is the one used.

As far as where that G-42xxxxx measurement ID is coming from, it has to be coming from somewhere (it doesn't just make them up randomly). In your Google Analytics account, go to Admin -> Data Streams -> [click on your stream for the property], then you should be able to see the Measurement ID associated with that stream. If the Measurement ID isn't matching up to any property you have on your Google Account, the only thing I can think of is double-check that the right Google Account is the one you linked (could also try linking your Google Account again to make absolutely certain it's the right Google Account). I've definitely seen stranger things than someone linking the wrong Google Account and then wondering where that property is in the normal Google Analytics interface (when looking via a different Google Analytics account).
Thanks, Shawn.
The measurement ID is correct in the data streams -> AVForums setting
1660051068443.png
I think like most people, I don't want to get in to the details, but just make it work.
For me the confusing thing is the difference between the property ID and the Measurement ID.

The dip in this graph is when better analytics was enabled.
Code:
https://www.avforums.com/admin.php?analytics/charts&uri=https%3A%2F%2Fwww.avforums.com%2F
1660051426535.png
After re-enabling Better Analytics, our reports on Google Analytics have dropped to zero traffic.
 
Last edited:
Thanks, Shawn.
The measurement ID is correct in the data streams -> AVForums setting
View attachment 271844
I think like most people, I don't want to get in to the details, but just make it work.
For me the confusing thing is the difference between the property ID and the Measurement ID.
Right, your previous screenshot had a G-2609xxx ID listed in your default XenForo settings. A G-XXXX value is supposed to be a measurement ID in Google Analytics. So I guess my question is where did you get that measurement ID that you manually had to enter there if it's not the measurement ID for the web stream you pulled up (it shows the measurement ID being G-42xxxx, which is the one this add-on used (and seems correct from your screenshots).

I guess it doesn't really matter, but I am curious where that G-2609xxx measurement ID came from.

The dip in this graph is when better analytics was enabled.
Code:
https://www.avforums.com/admin.php?analytics/charts&uri=https%3A%2F%2Fwww.avforums.com%2F
View attachment 271845
After re-enabling Better Analytics, our reports on Google Analytics have dropped to zero traffic.
As far as why this add-on didn't log data for you even though it was using the right Measurement ID for your web property, my guess is that you were using the option to host the Google Tag Manager JavaScript on your own domain, and that was combined with the fact that your web server is mis-configured. It looks like your web server is intercepting any request that ends in .js without checking if the file actually exists in the file system. So the request for the locally hosted JavaScript (gtm.js) is handled by your web server and it never passes it along to XenForo. You can see an example of this here:

At XenForo, the request for members.js is routed to XenForo application (you see an error from XenForo):



For your site, you don't get an error in XenForo, so the web server is not routing the request to XenForo, and instead handling the request on it's own:



It's not an issue with any extension in your setup, just .js. Change that same URL to have a random extension (for example .jj), and the web server correctly routes it to XenForo application:


So there's a couple things you can do here...

What I would do is set your web server up to internally handle .js requests only if the .js file actually exists in the file system (it can't do much if the file doesn't exist). How to configure your web server is probably outside the scope of setting up this add-on, because you've set it up in a non-standard way, but if you are using Nginx, the try_files directive is your friend (like if you have a location block handling .js requests, have that block use try_files to check if the file exists rather than blindly handling it). Then if the .js file isn't a static file in the file system, it will pass the request along to XenForo (which is the normal action anyway).

The other option is to simply disable the Host Google Tag Manager JavaScript on your own domain option. Then nothing is even trying to make the gtm.js request.
 
So I guess my question is where did you get that measurement ID that you manually had to enter there if it's not the measurement ID for the web stream you pulled up (it shows the measurement ID being G-42xxxx, which is the one this add-on used (and seems correct from your screenshots).

I was using the property ID.

The other option is to simply disable the Host Google Tag Manager JavaScript on your own domain option. Then nothing is even trying to make the gtm.js request.

I've done that as it's the simplest. Fingers crossed that it's the answer.
Really appreciate your help, Shawn, thank you.
I showed Better Analytics to our ad ops technician and she is excited at the prospect of getting all this data coming through.
 
I was using the property ID.
Ah... ya, Google Analytics 4 is a completely different beast than Universal (or Legacy). Probably best to just let go of everything you knew about the old versions because it's complete rewrite/rethinking of how things work (and also why you can't import data from old properties unfortunately).

I've done that as it's the simplest. Fingers crossed that it's the answer.
Really appreciate your help, Shawn, thank you.
I showed Better Analytics to our ad ops technician and she is excited at the prospect of getting all this data coming through.
No worries... it should be easy enough to make sure it's working. Just go into your Google Analytics web interface, go to Reports and then Realtime. That will show you data flowing via that property's data stream in realtime. If you see data flowing in, it should be good. If not, something else might be going on. But I would wager money the issue was that your web server wasn't passing along the .js HTTP request so no JavaScript was getting loaded.
 
I've done that as it's the simplest. Fingers crossed that it's the answer.
A quick skim and it looks like that solved the issue.

Unrelated, but.... omg have you seen how many http requests your site is doing and how many console errors are happening? If you look at XenForo admin -> Logs -> Client-side errors, I think you might have a lot in there.

But ya... the underlying issue seems to be sorted out, although personally I still think it wouldn't be a bad idea to get to the root of the issue in your web server, but the work-around is working it seems. :)
 
A quick skim and it looks like that solved the issue.

Unrelated, but.... omg have you seen how many http requests your site is doing and how many console errors are happening? If you look at XenForo admin -> Logs -> Client-side errors, I think you might have a lot in there.

But ya... the underlying issue seems to be sorted out, although personally I still think it wouldn't be a bad idea to get to the root of the issue in your web server, but the work-around is working it seems. :)
145,335 image not_loaded errors in a week at the home page can't be good. I've pointed our developer John at this thread.
Appreciate your insight very much.
 
145,335 image not_loaded errors in a week at the home page can't be good. I've pointed our developer John at this thread.
Appreciate your insight very much.
Assuming you just started using the addon (where it's working) 24 hours ago, that's more like 145k per day. ;) Ya, I'd check some of that out. I definitely feel like being able to see the client-side errors might give you an opportunity to optimize/fix some stuff. :)

Most likely not everything will be fixable since some browsers might be really silly (like someone using Netscape 1.0 from the 1990s), but if you see really high numbers (like 100,000+ images not loading in the last 24 hours), something might be going on. ;)
 
@digitalpoint two bugs:
Code:
GuzzleHttp\Exception\ServerException: Template admin:index error: Server error: `POST https://analyticsdata.googleapis.com/v1beta/properties/324705812:runRealtimeReport` resulted in a `500 Internal Server Error` response: { "error": { "code": 500, "message": "Internal error encountered.", "status": "INTERNAL" } } src/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

Code:
TypeError: Return value of DigitalPoint\Analytics\Pub\Controller\JavaScript::actionGtm() must be an instance of DigitalPoint\Analytics\Pub\Controller\object, instance of XF\Mvc\Reply\View returned src/addons/DigitalPoint/Analytics/Pub/Controller/JavaScript.php:41
Generated by: Unknown account Aug 31, 2022 at 2:24 PM
Stack trace
#0 src/XF/Mvc/Dispatcher.php(352): DigitalPoint\Analytics\Pub\Controller\JavaScript->actionGtm(Object(XF\Mvc\ParameterBag))
#1 src/XF/Mvc/Dispatcher.php(263): XF\Mvc\Dispatcher->dispatchClass('DigitalPoint\\An...', 'Gtm', Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\JavaScript), NULL)
#2 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\JavaScript), NULL)
#3 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#4 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#5 src/XF.php(517): XF\App->run()
#6 index.php(20): XF::runApp('XF\\Pub\\App')
#7 {main}
 
That's an internal server error on Google's web server side, not in your side. The only thing you can do about that would be to suppress the error that Google's server is returning, but it's probably a better idea to know if Google's servers are having issues vs. ignoring it and not know.

If you see it for an extended period of time, it would be worth looking at, but if it's transient (and it's working now), it was just a failed HTTP request to Google's servers (even Google has a web server error on occasion).

For the second error, is that something you are able to replicate? My guess is that it stems from the same issue (web server issue with Google's servers). Were those 2 errors around the same time?

At it's core, both of those errors involve making HTTP requests to Google's servers.
 
Top Bottom