[DigitalPoint] Better Google Analytics

[DigitalPoint] Better Google Analytics 1.0.7.2

No permission to download

digitalpoint

Well-known member
Asking this on behalf of a customer :) When attempting to select the GA4 property after connecting the GA account, this error pops up.
Looks to me like whatever Google Analytics account they linked, it is not an Google Analytics Administrator account for the Google Account that contains the website property. You can check the users and their allowed roles by going into the Google Analytics account, then going to Admin -> Account Access Management. If the Google Account you linked within the Xenforo -> Options -> Analytics area has a role of Analyst, Viewer or None, that account will not be able to make configuration changes via the API.

You could probably get away with having an Editor role, however I've not tried it. If that doesn't work, you may need to make them an Administrator role for the Google Analytics Account.

TL;DR
The Google "user" that is making the underlying API calls will need access to perform administrator-level functions in order to get measurement protocol secrets for the Analytics property (what that call is trying to do).
 

bzcomputers

Well-known member
Great addon, thanks for all the work.

One issue I'm seeing...
For custom pages/urls I have created outside of the XenForo framework the analytics icon link at the top of those pages has the wrong uri query string attached to it. All my custom pages seem to have the same "/community/index.php" uri appended.
 

digitalpoint

Well-known member
It's not doing anything special with custom vs. stock pages. When it builds the link, it's using the $xf.fullUri variable, which XenForo gets from $request->getFullRequestUri().

The add-on does not make any changes to how that's generated or stored by XenForo.

That being said, how do you even have a staff bar on a page outside of the XenForo framework? It's part of the XF framework.

For whatever custom thing you built, I'd make sure you have the normal XenForo request intact, as that's where the page URL is coming from (it's the same variable XenForo uses for it's share buttons, so I suspect XenForo's default share buttons wouldn't work there either).
 

bzcomputers

Well-known member
I guess I shouldn't have said outside of the XenForo Framework, because it does integrate with the framework just not through the built in paging system.

XenForo exists on my site in a subdirectory of the root and my custom pages (integrated within the framework) exist in both parent and sibling folders of XenForo. This means the XenForo board url (i.e. www.mydomain.com/community/) will not always be the base url for the page uri in my case (i.e. www.mydomain.com/custom-folder/custom-page/). This makes using $xf.fullUri incompatible in my case, and I believe in all cases an add-on has pages that don't exist as a child on the XenForo board url.

I might have to look at modifying the staff bar link to just use $_SERVER['REQUEST_URI'] instead.
 

digitalpoint

Well-known member
Ya, doing something custom and going outside of XenForo's normal routing/request system is probably outside the scope of what I can realistically support with the add-on.

Are you by chance doing something like overriding $_SERVER['REQUEST_URI'] as part of your add-on? I skimmed over how fullUri is built and it's simply looking to see if $_SERVER['IIS_WasUrlRewritten'] exists, and if it does, it returns $_SERVER['UNENCODED_URL'], otherwise it returns $_SERVER['REQUEST_URI'].

The only thing I can think of is if you are shoehorning your own values into those global variables (maybe that's how you are getting it to work in different directories, by tricking the router into thinking it's in the default directory maybe?).

There are other places where fullUri is used (like I mentioned earlier, things like the default XenForo share widget), so to me it would make sense to have your add-on actually return the fullUri properly even if that means you need to manually set it within your addon. Then you aren't going to need to make one off modifications for the staff bar (for this add-on) or potentially other things. Fix the return of that value if need be and you fixed the root of the problem. :)
 

rdn

Well-known member
Please provide your nginx vhost configuration.
I'm not using this addon anymore, so I forgot how I fixed it.
 

lucien_lies

Member
Please provide your nginx vhost configuration.
I'm not using this addon anymore, so I forgot how I fixed it.
you mean the rewrite config?

NGINX:
  location / {
    try_files $uri $uri/ /index.php?$uri&$args;
    index index.php index.html;
  }

  location /install/data/ {
    internal;
    allow 127.0.0.1;
    deny all;
  }

  location /install/templates/ {
    internal;
    allow 127.0.0.1;
    deny all;
  }

  location /internal_data/ {
    internal;
    allow 127.0.0.1;
    deny all;
  }

  location /src/ {
    internal;
    allow 127.0.0.1;
    deny all;
  }

or this one:

NGINX:
server
{
    listen 80;
    listen 443 ssl http2;
    server_name 5minutos.cu;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/foro;
   add_header 'Referrer-Policy' 'origin';
   add_header X-XSS-Protection "1; mode=block";
   add_header X-Frame-Options "SAMEORIGIN";
   add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
   add_header Set-Cookie "Path=/; HttpOnly; Secure";

    #SSL-START SSL related configuration, do NOT delete or modify the next line of commented-out 404 rules
    #error_page 404/404.html;
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END
    ssl_certificate    /www/server/panel/vhost/cert/5minutos.cu/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/5minutos.cu/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;

    #SSL-END

    #ERROR-PAGE-START  Error page configuration, allowed to be commented, deleted or modified
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END

    #PHP-INFO-START  PHP reference configuration, allowed to be commented, deleted or modified
    include enable-php-74.conf;
    #PHP-INFO-END

    #REWRITE-START URL rewrite rule reference, any modification will invalidate the rewrite rules set by the panel
    include /www/server/panel/vhost/rewrite/5minutos.cu.conf;
    #REWRITE-END

    # Forbidden files or directories
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    # Directory verification related settings for one-click application for SSL certificate
    location ~ \.well-known{
        allow all;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log /dev/null;
        access_log off;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log /dev/null;
        access_log off;
    }
    access_log  /www/wwwlogs/5minutos.cu.log;
    error_log  /www/wwwlogs/5minutos.cu.error.log;
}


the error:

1669262472113.png
 

rdn

Well-known member
I believe you can fix it with the following configuration:
NGINX:
location /javascript/gtm.js {
    try_files $uri /index.php?$uri&$args;
}
 

rdn

Well-known member
I think the URI was changed from this addon, try:
NGINX:
location /jc/gtm.js {
    try_files $uri /index.php?$uri&$args;
}

But I'm not sure why JC and not JS.
 

digitalpoint

Well-known member
You can disable hosting the JavaScript on your own domain if your web server is configured in an incompatible way. That’s the easiest fix.
 

lucien_lies

Member
You can disable hosting the JavaScript on your own domain if your web server is configured in an incompatible way. That’s the easiest fix.
My website is accessible from the internet but many of my users can only access the country's national network. That's why it was important to have it locally. What I did was switch from Nginx to OpenLiteSpeed and it worked perfectly
 

digitalpoint

Well-known member
digitalpoint updated [DigitalPoint] Better Google Analytics with a new update entry:

New metrics

A minor update with the following:
  • itemPurchaseQuantity metric updated to itemsPurchased (per breaking changes to Google Analytics Reporting API going into effect Dec 1, 2022)
  • New item-scoped metrics added to E-commerce section of weekly heat map (itemsAddedToCart, itemsCheckedOut, itemsViewed and itemsViewedInList)
  • Don't try to track emails being read if the outgoing email has no HTML part (emails being sent manually as 'Plain text')

Read the rest of this update entry...
 
Hi guys/girls,

Was waiting for something like this. Unfortunatly
getting the following error:

The following errors must be resolved before continuing:
  • This add-on cannot be installed/upgraded because the following files are missing: src/addons/DigitalPoint/Analytics/Admin/View/Report/HeatMap.php.
Can someone assist me here?

Greetings!
 
Top