[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
My guess is it’s just a client with a very old browser with crappy JavaScript implementation. If you are going to log client-Side errors, you just kind of have to be okay with the fact that you will never eliminate them completely. 😀
 
right. just realized i can disable this feature. i must have enabled everything after installing the addon 😬
It's of course up to you, but I find the client-side error option a good one to have enabled. As long as you aren't so OCD (hah) that you care when things show up. Turning it off doesn't fix the client-side errors (they are still happening), but you just aren't being told about them. The report is something I check once in awhile (not like a daily thing). If you start seeing thousands of the same error, it might be something you want to look into. Could also be something as simple as an image got moved and isn't loading for users any longer. It's not a bad thing to know about that sort of thing. But again... up to you. :)
 
Thank you for this add-on. I installed it and am exploring it. I assume once this add-on is added we should remove the GA4 (and prior analytics) tags in the page_container head area?

Your setup mentions to turn on the enhanced tracking feature in GA - mine was already ON. FYI

Also, all four "Organic google search..." report items are erroring out in your latest version (installed today)

GuzzleHttp\Exception\ClientException: Client error: POST https://analyticsdata.googleapis.com/v1beta/properties/285824249:runReport resulted in a 400 Bad Request response: { "error": { "code": 400, "message": "The dimensions and metrics are incompatible.", "status": "INVALID_AR (truncated...) in src/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php at line 113
  1. GuzzleHttp\Exception\RequestException::create() in src/vendor/guzzlehttp/guzzle/src/Middleware.php at line 66
  2. GuzzleHttp\Middleware::GuzzleHttp\{closure}() in src/vendor/guzzlehttp/promises/src/Promise.php at line 204
  3. GuzzleHttp\Promise\Promise::callHandler() in src/vendor/guzzlehttp/promises/src/Promise.php at line 153
  4. GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() in src/vendor/guzzlehttp/promises/src/TaskQueue.php at line 48
  5. GuzzleHttp\Promise\TaskQueue->run() in src/vendor/guzzlehttp/promises/src/Promise.php at line 248
  6. GuzzleHttp\Promise\Promise->invokeWaitFn() in src/vendor/guzzlehttp/promises/src/Promise.php at line 224
  7. GuzzleHttp\Promise\Promise->waitIfPending() in src/vendor/guzzlehttp/promises/src/Promise.php at line 269
  8. GuzzleHttp\Promise\Promise->invokeWaitList() in src/vendor/guzzlehttp/promises/src/Promise.php at line 226
  9. GuzzleHttp\Promise\Promise->waitIfPending() in src/vendor/guzzlehttp/promises/src/Promise.php at line 62
  10. GuzzleHttp\Promise\Promise->wait() in src/vendor/guzzlehttp/guzzle/src/Client.php at line 131
  11. GuzzleHttp\Client->request() in src/vendor/guzzlehttp/guzzle/src/Client.php at line 89
  12. GuzzleHttp\Client->__call() in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 15
  13. DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 16
  14. DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
  15. DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 254
  16. DigitalPoint\Analytics\Repository\Reporting->getChart() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 66
  17. DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts() in src/XF/Mvc/Dispatcher.php at line 352
  18. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
  19. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
  20. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
  21. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2352
  22. XF\App->run() in src/XF.php at line 524
  23. XF::runApp() in admin.php at line 13
 
I was unable to use the Style Chooser on my site at https://rvforums.com with "Track overlay as page view" enabled. I'm using a Pixel Exit theme, if that matters. Once I unchecked this option it worked again.
 
Thank you for this add-on. I installed it and am exploring it. I assume once this add-on is added we should remove the GA4 (and prior analytics) tags in the page_container head area?

Your setup mentions to turn on the enhanced tracking feature in GA - mine was already ON. FYI

Also, all four "Organic google search..." report items are erroring out in your latest version (installed today)

GuzzleHttp\Exception\ClientException: Client error: POST https://analyticsdata.googleapis.com/v1beta/properties/285824249:runReport resulted in a 400 Bad Request response: { "error": { "code": 400, "message": "The dimensions and metrics are incompatible.", "status": "INVALID_AR (truncated...) in src/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php at line 113
  1. GuzzleHttp\Exception\RequestException::create() in src/vendor/guzzlehttp/guzzle/src/Middleware.php at line 66
  2. GuzzleHttp\Middleware::GuzzleHttp\{closure}() in src/vendor/guzzlehttp/promises/src/Promise.php at line 204
  3. GuzzleHttp\Promise\Promise::callHandler() in src/vendor/guzzlehttp/promises/src/Promise.php at line 153
  4. GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() in src/vendor/guzzlehttp/promises/src/TaskQueue.php at line 48
  5. GuzzleHttp\Promise\TaskQueue->run() in src/vendor/guzzlehttp/promises/src/Promise.php at line 248
  6. GuzzleHttp\Promise\Promise->invokeWaitFn() in src/vendor/guzzlehttp/promises/src/Promise.php at line 224
  7. GuzzleHttp\Promise\Promise->waitIfPending() in src/vendor/guzzlehttp/promises/src/Promise.php at line 269
  8. GuzzleHttp\Promise\Promise->invokeWaitList() in src/vendor/guzzlehttp/promises/src/Promise.php at line 226
  9. GuzzleHttp\Promise\Promise->waitIfPending() in src/vendor/guzzlehttp/promises/src/Promise.php at line 62
  10. GuzzleHttp\Promise\Promise->wait() in src/vendor/guzzlehttp/guzzle/src/Client.php at line 131
  11. GuzzleHttp\Client->request() in src/vendor/guzzlehttp/guzzle/src/Client.php at line 89
  12. GuzzleHttp\Client->__call() in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 15
  13. DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 16
  14. DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
  15. DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 254
  16. DigitalPoint\Analytics\Repository\Reporting->getChart() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 66
  17. DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts() in src/XF/Mvc/Dispatcher.php at line 352
  18. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
  19. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
  20. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
  21. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2352
  22. XF\App->run() in src/XF.php at line 524
  23. XF::runApp() in admin.php at line 13
You shouldn't need to remove anything, unless you manually added something before. A normal installation of XenForo doesn't require you to go editing anything or any templates.

The organic search things, do require you to have a Search Console link in order to work (specifically a link to your Google Analytics 4 data stream) in your Google Search Console settings for your domain. Looks something like this:

1654443368158.webp

I probably should have mentioned that (oops). The data it charts is data that doesn't exist directly in your Google Analytics account (it comes from Google Search Console), so no way around that. I've made a change for the next version that will throw an exception and show the error in a more human readable way, but it will still throw an exception if you try to get that data and you don't have the link.

That being said, the error you are getting is something different. Not sure how it would be the case if it's a new installation, but is there somehow the new version of the add-in installed, but using the old PHP files (from before the organic stuff was an option)?

I was unable to use the Style Chooser on my site at https://rvforums.com with "Track overlay as page view" enabled. I'm using a Pixel Exit theme, if that matters. Once I unchecked this option it worked again.
Do you get any errors (server-side or in the browser console)? Hard to check on this end because I don't use Pixel Edit themes myself for anything. Do things work as expected for other overlays in that theme?
 
I'll look into the Google Search link later. I checked server error log and this is all that's in there (3 of them). I'm using PHP 8.1. I didn't turn on the layer tracking again once it worked in my theme. I'll have to test later and report back to see if it works in other than pixel exit themes.

  • GuzzleHttp\Exception\ClientException: Client error: POST https://analyticsdata.googleapis.com/v1beta/properties/285824249:runReport resulted in a 400 Bad Request response: { "error": { "code": 400, "message": "The dimensions and metrics are incompatible.", "status": "INVALID_AR (truncated...)
  • src/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

Stack trace​

#0 src/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 src/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 src/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 src/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 src/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run(true)
#5 src/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 src/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#7 src/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 src/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 src/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait()
#10 src/vendor/guzzlehttp/guzzle/src/Client.php(89): GuzzleHttp\Client->request('post', 'https://analyti...', Array)
#11 src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php(15): GuzzleHttp\Client->__call('post', Array)
#12 src/addons/DigitalPoint/Analytics/GoogleApi/Data.php(16): DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall('properties/2858...', Array)
#13 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(159): DigitalPoint\Analytics\GoogleApi\Data->runReport('properties/2858...', Array)
#14 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(254): DigitalPoint\Analytics\Repository\Reporting->runReport(Array)
#15 src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php(66): DigitalPoint\Analytics\Repository\Reporting->getChart(1651708800, 1654387200, '', 'organicGoogleSe...', 10, 'rvforums.com/')
#16 src/XF/Mvc/Dispatcher.php(352): DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts(Object(XF\Mvc\ParameterBag))
#17 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('DigitalPoint\\An...', 'Charts', Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Admin\Controller\Analytics), NULL)
#18 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Admin\Controller\Analytics), NULL)
#19 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#20 src/XF/App.php(2352): XF\Mvc\Dispatcher->run()
#21 src/XF.php(524): XF\App->run()
#22 admin.php(13): XF::runApp('XF\\Admin\\App')
#23 {main}

Request state​

array(4) {
["url"] => string(27) "/admin.php?analytics/charts"
["referrer"] => string(47) "https://rvforums.com/admin.php?analytics/charts"
["_GET"] => array(1) {
["analytics/charts"] => string(0) ""
}
["_POST"] => array(7) {
["_xfToken"] => string(8) "********"
["uri"] => string(13) "rvforums.com/"
["start"] => string(10) "2022-05-05"
["end"] => string(0) ""
["date_preset"] => string(2) "-1"
["dimension"] => string(31) "|organicGoogleSearchImpressions"
["min"] => string(2) "10"
}
}
 
Ah... okay, I see what's going on there (and it makes sense now that I think about it). Specifically, you were trying to report on a specific URL (by going to the chart from the staff menu bar). Since the underlying data comes from Google Search Console for the domain (that data isn't broken down by URL), the API call more or less barfs because it can't get the data only specific for that one page.

I'm going to make some changes so that the organic search options are disabled when you are reporting for a specific page (they will only work when you are reporting for the site as a whole).
 
I noticed the email notifications are getting utm_source tags etc. on the url's. I've turned off the email features I believe yet they are still getting linked as such. Is something set wrong? I don't want people seeing utm_source in the mobile phone notifications for emails as I'm seeing. I really don't need to track anything related to email notifications.
 

Attachments

  • options-analytics.webp
    options-analytics.webp
    64 KB · Views: 7
I noticed the email notifications are getting utm_source tags etc. on the url's. I've turned off the email features I believe yet they are still getting linked as such. Is something set wrong? I don't want people seeing utm_source in the mobile phone notifications for emails as I'm seeing. I really don't need to track anything related to email notifications.
Ya, there was an issue that was already fixed (but not rolled out yet).

In the meantime, if you don't need any email stuff (like you also aren't trying to have events for emails being sent), you can could comment out (or just remove) the renderMailTemplate() method completely in DigitalPoint\Analytics\XF\Mail\Mailer.php
 
Ya, there was an issue that was already fixed (but not rolled out yet).

In the meantime, if you don't need any email stuff (like you also aren't trying to have events for emails being sent), you can could comment out (or just remove) the renderMailTemplate() method completely in DigitalPoint\Analytics\XF\Mail\Mailer.php
I'll wait for the update that resolves this. Thank you.
 
digitalpoint updated [DigitalPoint] Better Google Analytics with a new update entry:

Minor usability update

  • Give a more human-readable error message if there was a problem with an API call
  • Disable Organic Google search dimension on chart when trying to report for a specific page (it's impossible to report on data coming from Google Search Console for a singular URL)
  • Fixed issue with the ability to disable link source tracking for emails

Read the rest of this update entry...
 
Are we still supposed to put the GA4 gtag code in our header? I had removed mine when I installed this add-on and I'm not seeing real time users, etc. I just put it back in until I learn more.
 
Are we still supposed to put the GA4 gtag code in our header? I had removed mine when I installed this add-on and I'm not seeing real time users, etc. I just put it back in until I learn more.
Not sure what you are referring to. You don't need to add/remove anything to any templates with this add-on. If you can point me to the instructions you followed to add something to your header, I can try to figure out what you are trying to do exactly.
 
Do I have to put this in my page_container within the HEAD tags for GA4 analytics?

<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=[removed]"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '[removed]'); </script>
 
Do I have to put this in my page_container within the HEAD tags for GA4 analytics?

<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=[removed]"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '[removed]'); </script>
No, the add-on does everything for you.

That being said, I went to the first site in your signature, and it looks like you have a misconfiguration with your web server. Specifically, the HTTP request for the JavaScript that the add-on loads is being intercepted by Apache and not being passed along to XenForo. If you look at this URL, see how there's an Apache error, not a XenForo error (the request never makes it to XenForo): https://rvforums.com/javascript/gtm.js?_v=1f28a2e9

It doesn't appear to be intercepting based on the .js extension, so my guess is that you have Apache to do something special if the URL has "javascript" in it or something. Only way to tell would be to look at your Apache config for your website.

Ultimately, that's why you aren't seeing anything flowing into Google Analytics. If you aren't able to sort out the Apache config, you can choose to not try and host the JavaScript on your own domain by disabling the Host Google Tag Manager JavaScript on your own domain option.
 
It seems this error, from a google search, is related to Google Tag Manager and being published or something along that line. I'm not using Google Tag manager. Is that required for your add-on?
 
Top Bottom