[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
I am getting this error when clicking on "Client side errors"

Code:
InvalidArgumentException: Please remove pageLocation to make the request compatible. The request's dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/ in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 31
DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 15
DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 524
DigitalPoint\Analytics\Repository\Reporting->getExceptions() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 156
DigitalPoint\Analytics\Admin\Controller\Analytics->actionExceptions() in src/XF/Mvc/Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2483
XF\App->run() in src/XF.php at line 524
XF::runApp() in admin.php at line 13

@digitalpoint

I'm getting a similar error for purchaseRevenue.

Code:
InvalidArgumentException: Please remove purchaseRevenue to make the request compatible. The request's dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/ in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 31
 
[LIST=1]
[*]DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 15
[*]DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
[*]DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 284
[*]DigitalPoint\Analytics\Repository\Reporting->getChart() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 86
[*]DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts() in src/XF/Mvc/Dispatcher.php at line 352
[*]XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
[*]XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
[*]XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
[*]XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2353
[*]XF\App->run() in src/XF.php at line 524
[*]XF::runApp() in admin.php at line 13
[/LIST]
 
Got this error:
Code:
Server error log

    League\Flysystem\FileNotFoundException: File not found at path: js_cache/e16d37f2b91d042d0c9558a3cddbb377.js src/vendor/league/flysystem/src/Filesystem.php:389

    Generated by: Bastty Mar 4, 2023 at 10:29 PM
Code:
Stack trace

#0 src/vendor/league/flysystem/src/Filesystem.php(194): League\Flysystem\Filesystem->assertPresent('js_cache/e16d37...')
#1 [internal function]: League\Flysystem\Filesystem->readStream('js_cache/e16d37...', Array)
#2 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(431): call_user_func_array('League\\Flysyste...', Array)
#3 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(395): League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod('readStream', Array)
#4 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(154): League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall('readStream', Array)
#5 src/vendor/league/flysystem/src/MountManager.php(345): League\Flysystem\EventableFilesystem\EventableFilesystem->readStream('js_cache/e16d37...')
#6 src/addons/DigitalPoint/Analytics/Repository/JavaScript.php(81): League\Flysystem\MountManager->readStream('js_cache/e16d37...')
#7 src/addons/DigitalPoint/Analytics/Pub/View/JavaScript/Proxy.php(9): DigitalPoint\Analytics\Repository\JavaScript->getFile()
#8 src/XF/Mvc/Renderer/AbstractRenderer.php(91): DigitalPoint\Analytics\Pub\View\JavaScript\Proxy->renderRaw()
#9 src/XF/Mvc/Renderer/Raw.php(39): XF\Mvc\Renderer\AbstractRenderer->renderViewObject('DigitalPoint\\An...', '', Array)
#10 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Raw->renderView('DigitalPoint\\An...', '', Array)
#11 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Raw), Object(XF\Mvc\Reply\View))
#12 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Raw), Object(XF\Mvc\Reply\View))
#13 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'raw')
#14 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#15 src/XF.php(524): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
Code:
Request state

array(4) {
  ["url"] => string(22) "/jc/gtm.js?_v=246edc35"
  ["referrer"] => string(19) "https://ivvvi.cool/"
  ["_GET"] => array(1) {
    ["_v"] => string(8) "246edc35"
  }
  ["_POST"] => array(0) {
  }
}

Delete
 
Got this error:
Code:
Server error log

    League\Flysystem\FileNotFoundException: File not found at path: js_cache/e16d37f2b91d042d0c9558a3cddbb377.js src/vendor/league/flysystem/src/Filesystem.php:389

    Generated by: Bastty Mar 4, 2023 at 10:29 PM
Code:
Stack trace

#0 src/vendor/league/flysystem/src/Filesystem.php(194): League\Flysystem\Filesystem->assertPresent('js_cache/e16d37...')
#1 [internal function]: League\Flysystem\Filesystem->readStream('js_cache/e16d37...', Array)
#2 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(431): call_user_func_array('League\\Flysyste...', Array)
#3 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(395): League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod('readStream', Array)
#4 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(154): League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall('readStream', Array)
#5 src/vendor/league/flysystem/src/MountManager.php(345): League\Flysystem\EventableFilesystem\EventableFilesystem->readStream('js_cache/e16d37...')
#6 src/addons/DigitalPoint/Analytics/Repository/JavaScript.php(81): League\Flysystem\MountManager->readStream('js_cache/e16d37...')
#7 src/addons/DigitalPoint/Analytics/Pub/View/JavaScript/Proxy.php(9): DigitalPoint\Analytics\Repository\JavaScript->getFile()
#8 src/XF/Mvc/Renderer/AbstractRenderer.php(91): DigitalPoint\Analytics\Pub\View\JavaScript\Proxy->renderRaw()
#9 src/XF/Mvc/Renderer/Raw.php(39): XF\Mvc\Renderer\AbstractRenderer->renderViewObject('DigitalPoint\\An...', '', Array)
#10 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Raw->renderView('DigitalPoint\\An...', '', Array)
#11 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Raw), Object(XF\Mvc\Reply\View))
#12 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Raw), Object(XF\Mvc\Reply\View))
#13 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'raw')
#14 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#15 src/XF.php(524): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
Code:
Request state

array(4) {
  ["url"] => string(22) "/jc/gtm.js?_v=246edc35"
  ["referrer"] => string(19) "https://ivvvi.cool/"
  ["_GET"] => array(1) {
    ["_v"] => string(8) "246edc35"
  }
  ["_POST"] => array(0) {
  }
}

Delete
Is the file there or is it actually missing?
 
@digitalpoint

I'm getting a similar error for purchaseRevenue.

Code:
InvalidArgumentException: Please remove purchaseRevenue to make the request compatible. The request's dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/ in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 31
 
[LIST=1]
[*]DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 15
[*]DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
[*]DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 284
[*]DigitalPoint\Analytics\Repository\Reporting->getChart() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 86
[*]DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts() in src/XF/Mvc/Dispatcher.php at line 352
[*]XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
[*]XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
[*]XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
[*]XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2353
[*]XF\App->run() in src/XF.php at line 524
[*]XF::runApp() in admin.php at line 13
[/LIST]
Ya, looks like Google made some more changes (new restrictions) on the Google API as far as reporting. Looks like they don't let you break down revenue by product sold any longer. Weird...
 
@digitalpoint

I'm getting a 204 No Content error in the Firefox console. It looks like it might be due to spaces in the page title in the GA URL?

POST https://www.google-analytics.com/g/collect?v=2&tid=G-KEL18891DN&gtm=31ab8910&_p=881930018&cid=238172932.1641092899&ul=en-us&sr=3440x1440&uaW=1&_s=1&uid=1&sid=3817289394&sct=412&seg=1&dl=https://www.domain.com/&dt=(35) Domain Title&en=page_view&_ee=1&epn.style_id=37&upn.uid=3&upn.user_group_id=5 [HTTP/3 204 No Content 21ms]
 
That's the normal/correct response from Google Analytics servers. Why Firefox is throwing that in it's console, I'm not sure. That's more a question for Firefox developers. But status code 204 (No Content) is correct.

If you look at the network connections for this thread, you can see Google Analytics is giving the same response here too. If Firefox isn't showing it for you here, maybe you have something configured differently for the site in question (maybe a Firefox debugging mode of some sort)?

HTTP 204 No Content simply means the request was successful, but there's intentionally no content returned with the http request (for things like analytics reporting).
 
That's the normal/correct response from Google Analytics servers. Why Firefox is throwing that in it's console, I'm not sure. That's more a question for Firefox developers. But status code 204 (No Content) is correct.

If you look at the network connections for this thread, you can see Google Analytics is giving the same response here too. If Firefox isn't showing it for you here, maybe you have something configured differently for the site in question (maybe a Firefox debugging mode of some sort)?

HTTP 204 No Content simply means the request was successful, but there's intentionally no content returned with the http request (for things like analytics reporting).

Good info, thanks. I'll keep an eye on it :)

Are you by chance using a really old version of Firefox? Looks like it was a bug that was fixed in Firefox about 7 years ago.


I might put off the occasional update, but I've never been that bad 🤣
 
When I enabled this addon, all the banner ads that powered by Google Ads disappeared because of this error. Any idea how to deal with it?

javascript​

Uncaught ReferenceError: googletag is not defined
 
When I enabled this addon, all the banner ads that powered by Google Ads disappeared because of this error. Any idea how to deal with it?

javascript​

Uncaught ReferenceError: googletag is not defined
Hard to say what's going on without seeing it, but if you are doing custom things with your ad serving that is doing something like injecting ad JavaScript into your google_analytics template, those things aren't going to get applied because XenForo's google_analytics template is completely overwritten with this add-on.

If you are doing that, it's going to be best to keep ad JavaScript separate from analytics JavaScript. The google_analytics template is intended to just be for google_analytics.

Not 100% sure that's what's going on in your case, just a guess. Either way, look at how your ad code is being added to your site and make sure it has nothing to do with the google_analytics template.
 
Hard to say what's going on without seeing it, but if you are doing custom things with your ad serving that is doing something like injecting ad JavaScript into your google_analytics template, those things aren't going to get applied because XenForo's google_analytics template is completely overwritten with this add-on.

If you are doing that, it's going to be best to keep ad JavaScript separate from analytics JavaScript. The google_analytics template is intended to just be for google_analytics.

Not 100% sure that's what's going on in your case, just a guess. Either way, look at how your ad code is being added to your site and make sure it has nothing to do with the google_analytics template.
You are absolutely right. I added the below google ad js at bottom of XF google_analytics. Where you suggest I should put these?
Code:
<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
</script>
<script>
 var gptAdSlots = [];
 googletag.cmd.push(function() {
 var mapping = googletag.sizeMapping().
 // Accepts both common mobile banner formats
  addSize([320, 0], [[320, 50], [300, 50], [300, 250]]).
  addSize([768, 0], [[728, 90], [234, 60], [160, 600], [120, 600], [120, 240], [1, 1]]). //tablet
  addSize([992, 0], [[728, 90], [300, 250], [300, 600], [160, 600], [1, 1]]). //desktop
  build();
    gptAdSlots[0] = googletag.defineSlot('/4409701/Quantnet_SitewideHeader_Leaderboard_728_90', [728, 90], 'div-gpt-ad-1507130335998-2').defineSizeMapping(mapping).addService(googletag.pubads());
    gptAdSlots[1] = googletag.defineSlot('/4409701/Quantnet_Sitewide_RightRectangular_300_250', [300, 250], 'div-gpt-ad-1507130335998-1').defineSizeMapping(mapping).addService(googletag.pubads());
    gptAdSlots[3] = googletag.defineSlot('/4409701/Mobile', [320, 50], 'div-gpt-ad-1507130335998-3').defineSizeMapping(mapping).addService(googletag.pubads());
//    gptAdSlots[4] = googletag.defineSlot('/4409701/Quantnet_Sitewide_Halfpage300x600', [300, 600], 'div-gpt-ad-1507130335998-0').defineSizeMapping(mapping).addService(googletag.pubads());
//     googletag.pubads().enableSingleRequest();
    googletag.enableServices();
  });
</script>
<!-- Global site tag (gtag.js) - Google Ads: 965378854 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-965378854"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-965378854'); </script>
 
What I would do is make your own template just so managing it is easier... for sake of an example, let's call it, google_ads.

Then if you make a Template modification for PAGE_CONTAINER, as a Simple replacement:

Find:
Code:
</head>

Replace:
Code:
<xf:include template="google_ads" />
</head>

Now you have a single template that is your own for managing your ads and the contents of it gets injected in the same place (right after the Google Analytics JavaScript) at the end of the <head> tag on every public page.

Having your own template/injection point for your code gives you more control and you don't need to rely on anything (like the google_analytics [or any other] template being overwritten or changed in a way that might affect your changes).

...also, I should have been more specific in my previous post. The google_analytics template isn't technically overwritten, it's simply not used is what's happening underneath it all. Semantics, but I like to give the correct information even if it doesn't really matter. hah
 
What I would do is make your own template just so managing it is easier... for sake of an example, let's call it, google_ads.

Then if you make a Template modification for PAGE_CONTAINER, as a Simple replacement:

Find:
Code:
</head>

Replace:
Code:
<xf:include template="google_ads" />
</head>

Now you have a single template that is your own for managing your ads and the contents of it gets injected in the same place (right after the Google Analytics JavaScript) at the end of the <head> tag on every public page.

Having your own template/injection point for your code gives you more control and you don't need to rely on anything (like the google_analytics [or any other] template being overwritten or changed in a way that might affect your changes).

...also, I should have been more specific in my previous post. The google_analytics template isn't technically overwritten, it's simply not used is what's happening underneath it all. Semantics, but I like to give the correct information even if it doesn't really matter. hah
Wise words, Shawn.
I usually add everything to the PAGE_CONTAINER template but this post says to use the helper_js_global template. I'm not up to date on the best location to use. Your thoughts?
 
Well, it's not how I would do it, but it's maybe slightly simpler in the short term because you don't need to setup a template modification to inject your header. Personally, I think the extra 20 seconds to make the template modification to inject your own template is worth it. Like you have no guarantee that helper_js_global won't change in some way that breaks what you are doing in a future version of XenForo. In fact you don't even have a guarantee that helper_js_global even exists in a future version. But ya, it would probably work.

I'm an engineer, so my brain likes to keep things separate for easy future management. Like maybe someone in the future is trying to find your ad code to make changes... doesn't make sense to look for it in a template called helper_js_global... even less sense for it to be in a template called google_analytics when it has nothing to do with Google Analytics. I try to think about making things easier in the future... what won't break in the future and will be easy to find if I forget where I put it (or someone else is looking for it).
 
Well, it's not how I would do it, but it's maybe slightly simpler in the short term because you don't need to setup a template modification to inject your header. Personally, I think the extra 20 seconds to make the template modification to inject your own template is worth it. Like you have no guarantee that helper_js_global won't change in some way that breaks what you are doing in a future version of XenForo. In fact you don't even have a guarantee that helper_js_global even exists in a future version. But ya, it would probably work.

I'm an engineer, so my brain likes to keep things separate for easy future management. Like maybe someone in the future is trying to find your ad code to make changes... doesn't make sense to look for it in a template called helper_js_global... even less sense for it to be in a template called google_analytics when it has nothing to do with Google Analytics. I try to think about making things easier in the future... what won't break in the future and will be easy to find if I forget where I put it (or someone else is looking for it).
You convinced to break out my tools.
I made a google_template and create a template modification to inject that template into the PAGE_CONTAINER.
It should be easier to maintain going forward.
My previous question remain, how do you choose the best template to inject JS code into? Is PAGE_CONTAINER the only choice?
 
Top Bottom