[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
recently installation then this server error on a regular basis

  • ErrorException: Google Analytics Measurement protocol debug: { "validationMessages": [ ] }
  • src/XF/Error.php:77

stack trace​

#0 src/XF.php(219): XF\Error->logError('Google Analytic...', false)
#1 src/addons/DigitalPoint/Analytics/GoogleApi/Measurement.php(25): XF::logError('Google Analytic...')
#2 src/addons/DigitalPoint/Analytics/Repository/Measurement.php(11): DigitalPoint\Analytics\GoogleApi\Measurement->__destruct()
#3 src/addons/DigitalPoint/Analytics/Pub/Controller/Beacon.php(44): DigitalPoint\Analytics\Repository\Measurement->collect('46da7701-bb8c-4...', Array, '47641')
#4 src/XF/Mvc/Dispatcher.php(352): DigitalPoint\Analytics\Pub\Controller\Beacon->actionImage(Object(XF\Mvc\ParameterBag))
#5 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('DigitalPoint\\An...', 'Image', Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\Beacon), NULL)
#6 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\Beacon), NULL)
#7 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#8 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#9 src/XF.php(524): XF\App->run()
#10 index.php(20): XF::runApp('XF\\Pub\\App')
#11 {main}

Request state​

array(4) {
["url"] => string(165) "/b/image.gif?p=gNtoqeiJm5cUSqRnYICaeatnUcBcmYyEp%2Foxc8wBp1ZNVtPQqzsiNbTDb%2FzjjbVleCW%2Bx091eM09R3hT4D1oGbOYNbAi7gWm1nyb8ZgGzgArbuOOTjFS8SaPAMwuEYYOx8Y6sBwSBg%3D%3D"
["referrer"] => bool(false)
["_GET"] => array(1) {
["p"] => string(140) "gNtoqeiJm5cUSqRnYICaeatnUcBcmYyEp/oxc8wBp1ZNVtPQqzsiNbTDb/zjjbVleCW+x091eM09R3hT4D1oGbOYNbAi7gWm1nyb8ZgGzgArbuOOTjFS8SaPAMwuEYYOx8Y6sBwSBg=="
}
["_POST"] => array(0) {
}
}

i notice there are posts from a year ago that state to turn off debug mode, is that still correct for this error ?
 
i notice there are posts from a year ago that state to turn off debug mode, is that still correct for this error ?
Yep, if you turn on debugging mode, you are going to get debugging info (it should be off by default, and only available to see/turn on if you have advanced options enabled). :)

Enables debugging so you can see events come across DebugView in Google Analytics. Additionally, this adds a debugging entry to your server error log when the Measurement Protocol is used for server-side events (for example emails being sent/viewed).
 
I looking to use this fantastic app, installed but after configuration I checked and found the Font Awesome disappeared and node titles moved to middle and few minor display issues. I attached screenshot displaying expected (Better Analytics 1.0.10 disabled) and impacted rendering (Better Analytics 1.0.10 enabled). I have enabled the add-on just now (not sure that will be any help) to see if someone could help to troubleshoot my forum [Masked] landing page
 

Attachments

  • StyleCSS_Expected_layout.webp
    StyleCSS_Expected_layout.webp
    36.3 KB · Views: 5
  • StyleCSS_impacted.webp
    StyleCSS_impacted.webp
    42.9 KB · Views: 5
Last edited:
If it’s only on a custom theme, you would want to talk to the theme developer. Does it work okay on a default XenForo theme?
 
It is not. Zaraz is custom system that relays events to Cloudflare via their backend. The only events you can use are the ones Zaraz has defined, and they have very few events they understand. See their developer reference here: https://developers.cloudflare.com/zaraz/web-api/

Coincidentally, this add-on started as a Zaraz add-on, but there were just too many limitations (GA4 events you couldn't use), too many bugs, and you are really flying blind (you send events to Zaraz and have no clue how [or even if] it's translating that on their backend). The main thing I wanted Zaraz for was so I could call the analytics JavaScript from my own domain vs. from googletagmanager.com.

There were just too many problems and limitations with Zaraz for my liking, so I turned this add-on into a specific Google Analytics add-on. And the Host Google Tag Manager JavaScript on your own domain setting I made for this add-on solved the thing that made me want to use Zaraz.

From Cloudflare's developer Discord in the #zaraz channel...
View attachment 269980

Notice the date on that was a few weeks before this add-on was released. That was basically when I decided I was tired of fighting with Zaraz's limitations and I'd be better off doing what I want directly. :)

But to answer your question, no... Zaraz is it's own thing and you can't send Google Analytics events (directly) to Zaraz. Rather you have to send Zaraz events (which there aren't many of) and it will translate them into Google Analytics for you. Zaraz is pretty good at a really vanilla Google Analytics replacement (like if you just wanted to track page views). For anything more advanced, it's not that great.

I'm wondering if your opinion of Zaraz has changed any over the past couple years. We did have Zaraz set up with GA4, took it down for a while because engagement time was way off. They've since fixed that issue and I have it set up again. Seems to be working fine. Also using their custom HTML tool to put in a couple other scripts.
 
I'm wondering if your opinion of Zaraz has changed any over the past couple years. We did have Zaraz set up with GA4, took it down for a while because engagement time was way off. They've since fixed that issue and I have it set up again. Seems to be working fine. Also using their custom HTML tool to put in a couple other scripts.
Not really... you just don't have the flexibility to do things you want to do (like track custom things). Zaraz ends up dumbing down GA4 to the lowest common denominator of all the analytics systems it supports. Since it's a one-size fits all thing, it works okay if you are just trying to do basic things like page view tracking, but beyond that it's pretty limited.

The thing I wanted when I first started working with Zaraz was to not have users pulling Google Analytics JavaScript from external domains (for example making a request to https://www.googletagmanager.com/gtag/js). But there just was so many bugs and issues and things you couldn't track I ended up giving up on it. And ultimately I ended making an option to serve the JavaScript from your own domain (an option in this addon), which addressed the only remaining upside I could see with Zaraz.

1705353932810.webp

If you are just wanting to do the most basic tracking (like just page views), then Zaraz is fine... although it will have a tendency to break because they aren't using official Google Analytics APIs to feed data into Google Analytics, so things will break (and I'm sure they will fix it in a timely manner when they do).

TL;DR: I don't really see an upside to Zaraz if you serve the Google Analytics JavaScript from your own domain, only downside.
 
Hey @digitalpoint I hope you're well.

I've been getting repeated errors such as this - Just thought I'd check in and see if you have any tips. Many thanks :)

Code:
Server error log
XF\ConnectedAccount\Http\HttpResponseException: Failed to refresh OAuth access token for baAnalyticsCredentials: Failed to request resource. HTTP Code: 400 src/XF/ConnectedAccount/Http/Client.php:67
Generated by: smooth-c 22 January 2024 at 9:36 PM
Stack trace
#0 src/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php(224): XF\ConnectedAccount\Http\Client->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), Array, Array)
#1 src/addons/DigitalPoint/Analytics/Repository/Analytics.php(50): OAuth\OAuth2\Service\AbstractService->refreshAccessToken(Object(OAuth\OAuth2\Token\StdOAuth2Token))
#2 src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php(39): DigitalPoint\Analytics\Repository\Analytics->refreshAnalyticsTokenIfNeeded()
#3 src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php(11): DigitalPoint\Analytics\GoogleApi\AbstractApi->getToken()
#4 src/addons/DigitalPoint/Analytics/GoogleApi/Data.php(27): DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall('properties/3164...', Array)
#5 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(164): DigitalPoint\Analytics\GoogleApi\Data->runRealtimeReport('properties/3164...', Array)
#6 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(563): DigitalPoint\Analytics\Repository\Reporting->runRealtimeReport(Array)
#7 src/addons/DigitalPoint/Analytics/Template/Callback/Analytics.php(167): DigitalPoint\Analytics\Repository\Reporting->getRealtime()
#8 src/XF/Template/Templater.php(1695): DigitalPoint\Analytics\Template\Callback\Analytics::getRealtime('', Array, Object(SV\AdvancedBbCodesPack\XF\Template\Templater))
#9 internal_data/code_cache/templates/l1/s0/admin/index.php(208): XF\Template\Templater->callback('DigitalPoint\\An...', 'getRealtime', '', Array)
#10 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(SV\AdvancedBbCodesPack\XF\Template\Templater), Array, NULL)
#11 src/addons/MaZ/AMP/Traits/Templater/XF22.php(52): XF\Template\Templater->renderTemplate('index', Array, true, NULL)
#12 src/addons/MaZ/AUN/XF/Template/Templater.php(39): MaZ\AMP\XF\Template\Templater->renderTemplate('admin:index', Array, true, NULL)
#13 src/XF/Template/Template.php(24): MaZ\AUN\XF\Template\Templater->renderTemplate('admin:index', Array)
#14 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#15 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:Index', 'admin:index', Array)
#16 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#18 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#19 src/XF/App.php(2352): XF\Mvc\Dispatcher->run()
#20 src/XF.php(524): XF\App->run()
#21 admin.php(13): XF::runApp('XF\\Admin\\App')
#22 {main}
Request state
array(4) {
  ["url"] => string(10) "/admin.php"
  ["referrer"] => string(41) "https://www.ddhp"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Thank you
 
Hey @digitalpoint I hope you're well.

I've been getting repeated errors such as this - Just thought I'd check in and see if you have any tips. Many thanks :)

Code:
Server error log
XF\ConnectedAccount\Http\HttpResponseException: Failed to refresh OAuth access token for baAnalyticsCredentials: Failed to request resource. HTTP Code: 400 src/XF/ConnectedAccount/Http/Client.php:67
Generated by: smooth-c 22 January 2024 at 9:36 PM
Stack trace
#0 src/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php(224): XF\ConnectedAccount\Http\Client->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), Array, Array)
#1 src/addons/DigitalPoint/Analytics/Repository/Analytics.php(50): OAuth\OAuth2\Service\AbstractService->refreshAccessToken(Object(OAuth\OAuth2\Token\StdOAuth2Token))
#2 src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php(39): DigitalPoint\Analytics\Repository\Analytics->refreshAnalyticsTokenIfNeeded()
#3 src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php(11): DigitalPoint\Analytics\GoogleApi\AbstractApi->getToken()
#4 src/addons/DigitalPoint/Analytics/GoogleApi/Data.php(27): DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall('properties/3164...', Array)
#5 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(164): DigitalPoint\Analytics\GoogleApi\Data->runRealtimeReport('properties/3164...', Array)
#6 src/addons/DigitalPoint/Analytics/Repository/Reporting.php(563): DigitalPoint\Analytics\Repository\Reporting->runRealtimeReport(Array)
#7 src/addons/DigitalPoint/Analytics/Template/Callback/Analytics.php(167): DigitalPoint\Analytics\Repository\Reporting->getRealtime()
#8 src/XF/Template/Templater.php(1695): DigitalPoint\Analytics\Template\Callback\Analytics::getRealtime('', Array, Object(SV\AdvancedBbCodesPack\XF\Template\Templater))
#9 internal_data/code_cache/templates/l1/s0/admin/index.php(208): XF\Template\Templater->callback('DigitalPoint\\An...', 'getRealtime', '', Array)
#10 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(SV\AdvancedBbCodesPack\XF\Template\Templater), Array, NULL)
#11 src/addons/MaZ/AMP/Traits/Templater/XF22.php(52): XF\Template\Templater->renderTemplate('index', Array, true, NULL)
#12 src/addons/MaZ/AUN/XF/Template/Templater.php(39): MaZ\AMP\XF\Template\Templater->renderTemplate('admin:index', Array, true, NULL)
#13 src/XF/Template/Template.php(24): MaZ\AUN\XF\Template\Templater->renderTemplate('admin:index', Array)
#14 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#15 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:Index', 'admin:index', Array)
#16 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#18 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#19 src/XF/App.php(2352): XF\Mvc\Dispatcher->run()
#20 src/XF.php(524): XF\App->run()
#21 admin.php(13): XF::runApp('XF\\Admin\\App')
#22 {main}
Request state
array(4) {
  ["url"] => string(10) "/admin.php"
  ["referrer"] => string(41) "https://www.ddhp"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Thank you
Looks like something is wrong with your OAuth token. If it's something consistent (API calls aren't working at all, at any point), try relinking your Google Analytics account (it doesn't hurt to do that even if it works sometimes). It could be a scenario where permission was granted initially but then revoked later at the Google Account level (your XenForo install has a OAuth token, but it's no longer valid because it was revoked). In that scenario, when it tries to exchange an expired token for a new one, it fails because the old one was revoked.

TL;DR: try relinking your Google Account.
 
Hi @digitalpoint
I just moved my site to another server and got these errors. Can you please let me know how to remedy it?
Thank you.
Server error log
  • ErrorException: Google Analytics Measurement protocol debug: { "validationMessages": [ ] }
  • src/XF/Error.php:77
  • Generated by: Unknown account
  • 2/23/24 at 10:51 AM

Stack trace​

#0 src/XF.php(219): XF\Error->logError('Google Analytic...', false)
#1 src/addons/DigitalPoint/Analytics/GoogleApi/Measurement.php(25): XF::logError('Google Analytic...')
#2 src/addons/DigitalPoint/Analytics/Repository/Measurement.php(11): DigitalPoint\Analytics\GoogleApi\Measurement->__destruct()
#3 src/addons/DigitalPoint/Analytics/Pub/Controller/Beacon.php(34): DigitalPoint\Analytics\Repository\Measurement->collect('313e40b1-40cf-4...', Array, '50770')
#4 src/XF/Mvc/Dispatcher.php(352): DigitalPoint\Analytics\Pub\Controller\Beacon->actionImage(Object(XF\Mvc\ParameterBag))
#5 src/XF/Mvc/Dispatcher.php(258): XF\Mvc\Dispatcher->dispatchClass('DigitalPoint\\An...', 'Image', Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\Beacon), NULL)
#6 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(DigitalPoint\Analytics\Pub\Controller\Beacon), NULL)
#7 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#8 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#9 src/XF.php(524): XF\App->run()
#10 index.php(20): XF::runApp('XF\\Pub\\App')
#11 {main}

Request state​

array(4) {
["url"] => string(213) "/b/image.gif?p=HjKHBP7QhqGmr0hxgxUWwRsk%2F%2FKu79TPQqXBXn6%2BGvCwLVhrmHgm7RAe7DJY10yl%2B9tDS3ocHXTBFz%2BFAPxo58Qzx%2B6R1ZudAc0zD8YXFAQ8ri%2BR%2Fp91bEmPiQVZ06lCXrTnlBom0%2BDUyZNsALdJH5MfdVHAyZ1Wbkh7fRNTciAgCsuuJpOY"
["referrer"] => bool(false)
["_GET"] => array(2) {
["/b/image_gif"] => string(0) ""
["p"] => string(180) "HjKHBP7QhqGmr0hxgxUWwRsk//Ku79TPQqXBXn6+GvCwLVhrmHgm7RAe7DJY10yl+9tDS3ocHXTBFz+FAPxo58Qzx+6R1ZudAc0zD8YXFAQ8ri+R/p91bEmPiQVZ06lCXrTnlBom0+DUyZNsALdJH5MfdVHAyZ1Wbkh7fRNTciAgCsuuJpOY"
}
["_POST"] => array(0) {
}
}
 
I turned it on prior to the server migration but no error, these only show up after the move so I worry if it's something I need to change because of the new server. Is it?
I have turn it off now.
Well I can’t really speak as to why it wouldn’t have done the same on the old server, but what you are seeing there (debugging info sent to your server error log when the debug option is on) is how it’s intended to work.

So ya… basically disable debugging if you don’t want the debugging info. 😀
 
Installed 2.3 beta 2 and got this issue.

  • ErrorException: Fatal Error: Could not check compatibility between DigitalPoint\Analytics\XF\Mail\Mailer::send(Swift_Mime_SimpleMessage $message, ?Swift_Transport $transport = null, ?array $queueEntry = null, $allowRetry = true) and XF\Mail\Mailer::send(Symfony\Component\Mime\Email $email, ?Symfony\Component\Mailer\Transport\AbstractTransport $transport = null), because class Swift_Mime_SimpleMessage is not available
  • src/addons/DigitalPoint/Analytics/XF/Mail/Mailer.php:68
  • Generated by: Unknown account
  • 3/27/24 at 12:20 PM

Stack trace​

#0 [internal function]: XF::handleFatalError()
#1 {main}

Request state​

array(4) {
["url"] => string(91) "/admin.php?login/two-step&provider=email&_xfRedirect=https%3A%2F%2Fsite.com%2Fadmin.php"
["referrer"] => string(96) "https://site.com/admin.php?login/two-step&_xfRedirect=https://site.com/admin.php"
["_GET"] => array(3) {
["login/two-step"] => string(0) ""
["provider"] => string(5) "email"
["_xfRedirect"] => string(30) "https://site.com/admin.php"
}
["_POST"] => array(0) {
}
}
 
@Andy.N - I haven't fully tested this (I don't have a 2.3 site in full production), but if you replace the addons\DigitalPoint\Analytics\XF\Mail\Mailer.php file with this one, it should (hopefully) work with 2.3.

Let me know if you try it.
 

Attachments

Does this mod use minimal google analytics? Is mga advisable?


Minimal Google Analytics Snippet​

A simple snippet for tracking page views on your website without having to add external libraries. Also works for single page applications made with the likes of react and vue.js.

Before​

Google Tag Manager + Analytics = 73kB

After​

Snippet = 1.5kB

How does this work?​

This snippet sends page views directly to the Google Analytics API. There is no need to add the Google Tag Manager and Analytics libraries anymore. That not only saves bandwidth, it can also have a huge positive impact on the loading speed of your website. You should not use this if you want to use advanced features like tracking AdWords.
 
Top Bottom