[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.10

No permission to download
My Matomo installation recently stopped tracking. I was able to resolve the problem by disabling the Better Analytics add-on. Once disabled, the Matomo javascript returned to source via the Matomo Analytics add-on. There appears to be an add-on conflict. Just FYI.
 
Last edited:
Basically the OAuth2 flow looks like this:
  1. Store some info about the requested credentials in the admin session for the user.
  2. Redirect the user to the page to request permission via Google OAuth2.
  3. User allows access to Google Analytics.
  4. User gets redirected back to the admin area (that's the URL you saw that had the code=xxxxx in it.
  5. System retrieves the credential info stored in the admin session for the user in step #1.
  6. Exchange the one-time use code with an OAuth2 Access token.
The best I can tell, it's failing at step #5... retrieving the info that was supposed to be stored in step #1 from the user's admin session.

If the admin session for the user was somehow reset, reloading the URL with the code=xxxx in it won't help because the missing bit of info from the session is needed.

I'd maybe just try the Link Google account button again. If XenForo requires you to re-login when you are returned, that's going to be a sign that the user's admin session disappeared.

Also, not sure what would happen if you denied the permission request, but it definitely won't work if you deny the requested permission (it doesn't ask for the permission "just because", it asks because it's needed).
I am still having issues. When I click on the link google account it opens a new window. You said something about sessions which would than start a new session via the new window. Maybe that's the issue?? It opens a new window?

Any help would be much appreciated.
Thanks,
Itworx4me
 
My Matomo installation recently stopped tracking. I was able to resolve the problem by disabling the Better Analytics add-on. Once disabled, the Matomo javascript returned to source via the Matomo Analytics add-on. Just FYI. There appears to be an add-on conflict. Just FYI.
Does Matomo add-on work with the default XenForo Google Analytics setup (if you were running both concurrently)?

The core JavaScript that Better Analytics adds is by simply overwriting XenForo’s default google_analytics template, so if Matomo is doing the same thing, you wouldn’t be able to use both concurrently (you also wouldn’t be able to use Google Analytics in a stock XF setup either).

I am still having issues. When I click on the link google account it opens a new window. You said something about sessions which would than start a new session via the new window. Maybe that's the issue?? It opens a new window?

Any help would be much appreciated.
Thanks,
Itworx4me
What browser are you using? Normally a new XF session isn’t started in each window. Like if you are logged into the admin area, open a new window and go to the admin area, do you need to actually log in again?
 
Yes it makes me log in again
Okay, so I'd say it's safe to say that's the issue right there. That when you come back, you aren't using the same session as you started with. Maybe you have some browser extension installed that clears cookies when you open a new window or something? Just to get around this (you only need to do the authentication once), can you do it from a different browser/device? Could just do it from an iPhone/Android without any issues. Again, it only needs to be able to do it the one time... going forward it won't matter what sort of weirdness your browser is doing. :)
 
Okay, so I'd say it's safe to say that's the issue right there. That when you come back, you aren't using the same session as you started with. Maybe you have some browser extension installed that clears cookies when you open a new window or something? Just to get around this (you only need to do the authentication once), can you do it from a different browser/device? Could just do it from an iPhone/Android without any issues. Again, it only needs to be able to do it the one time... going forward it won't matter what sort of weirdness your browser is doing. :)
I tried Edge and my iPhone. They both asked me to sign into Xenforo. :(
 
Hmmm… not sure. I just tried with the following:

macOS / Chrome
macOS / Safari
macOS Firefox
Linux / Chrome
iOS / Chrome
iOS / Safari

All worked as expected (didn’t ask to re-login to the admin control panel when it was returned). Basically if you can’t use the same session upon return, it’s not going to work (it’s also the exact same way XenForo does OAuth2 authentication for other things like the setup of sending email via Gmail).

It’s definitely not normal behavior for a new window to log you out of the admin area. But without being able to replicate it, not even sure what to look at. Can you go to a friend’s computer that might have more default browser settings/behavior somehow?
 
It has been 4 days and still no data for me in Google Analytics. If I deactivate the addon, it goes back to the old GA3 property. I think there must be a bug somehow as it didn't register it.

So I will first manually enter the property ID, wait couple of days and then activate the addon.

One question, do we enter the measurement ID or stream ID in XF?
 
It's pretty easy to see if data is flowing from your end by looking in the browser DevTools under the Network tab. You can see events going to https://www.google-analytics.com/g/collect

If you want me to look, give me your site URL and I can look for you.

If you are talking about the default Google Analytics setup for XenForo, it's the measurement ID.
 
  • Like
Reactions: sbj
I have error, when i will check the charts "Organic Google search impression, click, click through rate, avergade position.

InvalidArgumentException: Search Console fields require an active link to be used. in src/addons/DigitalPoint/Analytics/GoogleApi/AbstractApi.php at line 23
  1. DigitalPoint\Analytics\GoogleApi\AbstractApi->makeApiCall() in src/addons/DigitalPoint/Analytics/GoogleApi/Data.php at line 16
  2. DigitalPoint\Analytics\GoogleApi\Data->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 159
  3. DigitalPoint\Analytics\Repository\Reporting->runReport() in src/addons/DigitalPoint/Analytics/Repository/Reporting.php at line 254
  4. DigitalPoint\Analytics\Repository\Reporting->getChart() in src/addons/DigitalPoint/Analytics/Admin/Controller/Analytics.php at line 66
  5. DigitalPoint\Analytics\Admin\Controller\Analytics->actionCharts() in src/XF/Mvc/Dispatcher.php at line 352
  6. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
  7. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
  8. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
  9. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2352
  10. XF\App->run() in src/XF.php at line 524
  11. XF::runApp() in admin.php at line 13
 
Ya, there's no way around that... the Organic Google dimensions require an active link to your Google Search Console property in order to report on them (the data comes from the Search Console, not Google Analytics directly).

In your Google Analytics settings, you can go to your property settings, then under "Product Links", there's an option for "Search Console Links".
 
Just spitballing here, since we have this addon in common with each other, how about if there would be a way to compare/share our stuff with each other anonymously?

For example one of my complaints about my own forum is that compared to the pageviews/usage my activity is below my expectations. I can't get the users to post something. It would be nice to see how other forums are doing compared to their sizes of course. Maybe this addon (or a new one) could make something like that possible for the benefit of all of us. With the right algorithm this addon could show us our strengths and weaknesses. Obviously only who wants to opt-in and anonymously. But I am just throwing this idea around, it is not something really that important to have. You already provide such big addons for free. But I can only see a handful of devs who would be capable of doing something like that, and thought asking doesn't hurt anyone :).
 
Just spitballing here, since we have this addon in common with each other, how about if there would be a way to compare/share our stuff with each other anonymously?

For example one of my complaints about my own forum is that compared to the pageviews/usage my activity is below my expectations. I can't get the users to post something. It would be nice to see how other forums are doing compared to their sizes of course. Maybe this addon (or a new one) could make something like that possible for the benefit of all of us. With the right algorithm this addon could show us our strengths and weaknesses. Obviously only who wants to opt-in and anonymously. But I am just throwing this idea around, it is not something really that important to have. You already provide such big addons for free. But I can only see a handful of devs who would be capable of doing something like that, and thought asking doesn't hurt anyone :).
Mmmmm... to be honest, that's probably going to be outside the scope of what I want to build. While I could technically do it, it would be a lot of work. I don't have access to anyone's data (the API credentials this add-on uses is kept within the site it's installed on and never leaves). So I couldn't purely do it on my end... would need to be something that sites choose to opt into, then run a cron job on their end once in awhile that grabs data from their property via API, then pushes that data to my servers (it would need a central place to house all that data). So then I'm storing everyone's Analytics data just because I'm nice and blah, blah... Then I legally become people's data processor so I'm now legally bound to all sorts of things like Europe's GDPR even though I'm not in Europe. There's a whole list of things I wouldn't want to do (just starting with the time required to build it). :)

That being said, there might be something already like that out there since it wouldn't really be specific to XenForo, rather just sites using Google Analytics, so maybe it's already out there and has a zillion sites already using it. Maybe... :)
 
Yeah, the legal aspects are just crazy. I knew the idea was "problematic" but perhaps there could have been ways to do it without getting into that mess. Of course besides it would be a lot of work to do in first place. As I said, I was just spitballing. I am not interested in how other sites are doing, just in how other XF installations are doing. For example do sites with stock installations do better than with custom designs? Do they offer dark themes or light themes? Stuff like that to optimize our sites. Every inch counts. Would have been great to have such stats but not worth the trouble. Thanks for answering, much appreciated. This addon is still great for sure.
 
My guess is the things the successful sites are doing has nothing to do with XenForo, rather they are offering something that people need/want (whatever that may be). As in solving people's problems. Simple things like light/dark themes aren't really a reason for people to visit a site I feel like. I prefer dark themes myself, but I still come to xenforo.com and don't come any less than if there was a dark theme for example.

My iolabs.io site is built on XenForo, has literally 1 total thread, just someone asking how to pay because they want to buy a "user upgrade" that costs anywhere from $25 - $100,000. No one comes there for the theme or forum or anything like that. People come because they want to look at the billions of pieces of data it has on offer. :)
 
Yeah, of course people don't come for the theme. But statistical analysis can provide meaningful results. Such as like say from 1000 successful sites 847 use a dark theme. Now obviously they are being successful for other reasons, for content, etc. But still seeing the trend that dark themes are preferred means something. As those successful sites have usually large userbases and they can measure what of the available designs are used the most. And when in general for successful sites dark themes are prefered, I would be inclinded to change my site's theme to a dark one. It will not magically grant me new users or make my forum more successful, but most likely it will enhance the experience of the current/existing users. As I said, every inch counts.

One can not deduct such answers from simply asking 10 forum owners. There needs to be a decent big pool of information to make such statements. And perhaps this addon could have been a gate to a shared pool of information since it is about "analytics" ;). But all good. Having asked about it is good enough for me, thanks for the considerations in any case.
 
Another thing I just thought of... Is your IP address changing rapidly by chance? XenForo also invalidates a session when your IP address changes.
My IP address is behind Cloudflare. If it were to change it would be at there end. Still no luck in getting this to work.
 
Top Bottom