I Can't Authorise Google Analytics in Sub-Sites

Hi there,

I'm trying to authorise Google Analytics from within a sub-site (that has a mapped domain) but every time I try, Google asks to allow access to my primary domain (ThinkBiGSites.co.uk) rather than the sub-domain (TheOutsourcedFinanceDirector.com) and, as my primary domain's already got access, when I click to 'Allow' access, I simply get re-directed from the Google authorisation page to my primary home page, without being provided with an authorisation code.

This means I'm unable to select the appropriate analytics property in the sub-site as there isn't a drop down list of properties that are avaiable.

If I try to add the property analytics code manually, Google Analytics+ seems to ignore the code and simply continue to use the primary code for the network and show site data based on that.

This used to work without any issue and I have other domains that are still showing their own analytics code and data within the sub-site dashboard. However, I can't seem to get authorisation for this particular sub-site - and I believe I've had this issue before but didn't raise a ticket at the time.

For some time, now, I've been having problems with your Domain Mapping plugin and I can't help but think that the two issues may be connected because the Domain Mapping issues have included sites being accessible via both the mapped domain and the original domain, despite the fact that I've set it to only allow the mapped domain.

This has never been fixed - I just found a work around (I use the native WordPress Domain Mapping to change the url of the sub-site in the settings).

I may be wrong but this just 'feels' like it's connected.

Kindest regards,

Steve

  • Kasia Swiderska

    Hello Steve,

    I'm sorry to hear this is not working correctly on your site.

    (TheOutsourcedFinanceDirector.com) and, as my primary domain's already got access, when I click to 'Allow' access, I simply get re-directed from the Google authorisation page to my primary home page, without being provided with an authorisation code.

    I can see this issue on your site, however when I replicate the same settings (latest Domain Mapping and also used with it a native WordPress mapping way) on my site I was not able to recreate this issue.
    On subsite with mapped domain I was able to get the access code and there was no redirects to main site like it happens on your site.
    It is very possible it is caused by something other than Domain Mapping on your site.

    I would like to see if there is anything in debug.log after trying to login to Google account. Please enable debug mode: open your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:
    define('WP_DEBUG', true);
    In order to enable the error logging to a file on the server you need to add yet one more similar line:

    define( 'WP_DEBUG_LOG', true );

    In this case the errors will be saved to a debug.log log file inside the /wp-content/directory.

    Depending on whether you want your errors to be only logged or also displayed on the screen you should also have this line there, immediately after the line mentioned above:

    define( 'WP_DEBUG_DISPLAY', false );

    The wp-config.php is located in your WordPress root directory. It’s the same file where the database configuration settings are. You will have to access it by FTP or SFTP in order to edit it.

    When its enabled please try logging again to get the issue with redirect.

    I would need then to see content of the debug.log file - so please upload it to service like a Dropbox and paste link here.

    If I try to add the property analytics code manually, Google Analytics+ seems to ignore the code and simply continue to use the primary code for the network and show site data based on that.

    I have checked source of the site and I can see that both codes: network and the subsite one is added there correctly.
    Where do you see network data for that subsite - in Google Analytics? Because I checked Statistics in Dashboard for this site and it only shows data for this particular subsite, not for the network.

    kind regards,
    Kasia

  • Steve - Just Think BiG

    Hi Kasia,

    I've activated the debug log as per your instructions and have tried to verify Google Analytics on several occasions, so, you should see the problem in the log.

    I've activated FTP temporarily for another issue (see here) and I've added the access details to the notes section where I've extended the support access.

    If you need anything else, please let me know.

    Kindest regards,

    Steve

  • Kasia Swiderska

    Hello Steve,

    Debug.log was there, but nothing was generated for this particular action - to be sure I forced creation new file and run google authorization twice and new debug.log was not created.
    I spoke with developer about this problem and they think it might be related to cookies, however they need to take a closer look on what is happening there.
    For the time they will be checking can you keep the FTP account active? As soon they will be any feedback about this issue they will reply here.

    kind regards,
    Kasia

  • Kasia Swiderska

    Hello Steve,

    Oh, I got info about workaround that should allow you to login to the google account on that subsite. I just tested it on my account and it worked.
    When after clicking that button and when page does the redirect to main site, replace domain to subsite domain (but leave everything that is after the domain) and then hit enter.
    It should redirect to GA settings page on subsite and you should be logged in and able to select code for analytics from dropdown.
    Let me know if this will work also for you.

    kind regards,
    Kasia

  • Konstantinos Xenos

    Hi Steve - Just Think BiG ,

    Unfortunately on all my tests I couldn't replicate the issue still at all.

    The only difference between my various setups that I've tested and your setup is that I'm not using any extra protection ( wordfence, firewall etc ) and all of the Domain Mapping checks are Valid. I checked multiple of your subsites and the mapping Health Status always returns invalid. This means that the plugin couldn't reach the domain properly even though it mapped it ( as there is an option in the settings that you can make the bind ignoring the check status ).

    Might there be an issue with the how the DNS propagates or something like that ? Unfortunately I can only speculate at this point, since I don't have any other clues of what might be actually going wrong here as there's no other errors ( at least not code-wise ).

    Best regards,
    Konstantinos

  • Steve - Just Think BiG

    Hi Kasia,

    Domain Mapping used to work perfectly until I reported the problem to you - which was a while ago now. Also, I never had the problem with Google Analytics until recently, either.

    This appears to suggest that something's changed after an update, at some point.

    Given that you can't reproduce the problem at your end, I am wondering whether there's something amiss with my installation.

    I've been thinking about this and there are two specific events that come to mind.

    1) I remember having a problem with the site and I ended up restoring it using a managed backup from the hub. When I restored it, there was an error message, which concerned me at the time. However, when I checked the site, everything seemed to work as it had done before, without any issue.

    2) I moved my hosting from one provider to another. My new provider imported the site from the old host as part of their sign-up offering and one consequence of that is that there are a number of files on the server that I don't see when I install new sites. I also had a problem in that the file manager on that install has restricted privileges and i can't delete certain files myself.

    Anyway, as a result of the above, I wonder whether there may be some kind of issue/conflict that's occurred as a result of one of these events - or the combination of them.

    I've recently set up a completely new multisite install, which I'm going to use for my own sites. I've migrated one across but have a few more to migrate.

    My instinct is not to use a snapshot to move the site but to manually move them i.e copy and paste. Fortunately, the sites aren't too big but I'm keen to have the new install completely independent from anything on the old install.

    This will allow me to test issues happening on the old install to see whether the new install suffers the same problems.

    Anyway, it's just a thought but I'm keen to see if it works.

    Regards,

    Steve

  • Konstantinos Xenos

    Hi again Steve - Just Think BiG ,

    Since you're mentioning that you have been gone through updates / migrations / dns changes because of migrations / permission issues / reverted backups etc there's a really wide area of why this could be happening and maybe that's why it's not easy for us to replicate the issue on fresh installations.

    I can make 2 suggestions to try and figure out what might be going wrong:

    1. You can provide us access to a staging copy of the website if possible so we can debug freely without stressing out your live site.

    2. Since there is a workaround that we can fall back to for the time being, we could de-authorize the current GA setup for this particular site so I can re-try to set it up via the normal route and see exactly where the problem is. This would mean though that I'll be working on your live environment so make sure to keep a full backup first. If you like me to see the issue on your live site and debug it there you can send me the information needed privately through our contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question by following this example:

    Subject: "Attn: Konstantinos Xenos"
    
    - Admin login ( if Multisite please provide Super Admin details ):
    Admin Username:
    Admin Password:
    Login URL: 
    
    - FTP credentials
    Hostname:
    Username:
    Password:
    Port:
    Key-File ( and password ) if needed
    
    - Server Admin ( CPanel / Plesk )
    Username:
    Password:
    Login URL:
    
    - Link back to this thread for reference
    - Any other relevant URLs -or- information regarding the issue that was not included in this thread

    Regards,
    Konstantinos

  • Steve - Just Think BiG

    Hi Konstantinos,

    Because I've had a few challenges that don't seem to be happening elsewhere, I've started to move some of my sites off that particular multisite install to a new one and I want to do a little testing of my own to see whether any of these challenges still exist on the new installs so, for now at least, hold tight.

    One question though: I plan on using snapshots of my sub-sites from the existing install to move those sub-sites to the new one. Is that likely to import any existing issues?

    My logic is that the sub-site snapshots don't include any global files, just those relevant to the sub-site. If doing this is likely to import the issue, it's going to be a much longer process.

    A second question is: If I want to import the users for my sub-sites, how do I do that using Snapshot?

    Regard,

    Steve

  • Kasia Swiderska

    Hello Steve,

    I'm sorry for the late response on my side!

    One question though: I plan on using snapshots of my sub-sites from the existing install to move those sub-sites to the new one. Is that likely to import any existing issues?

    My logic is that the sub-site snapshots don't include any global files, just those relevant to the sub-site. If doing this is likely to import the issue, it's going to be a much longer process.

    At this stage or troubleshooting we are not sure. Because if the problem lays somewhere in DB and not strictly on server side - then using Snapshot it will be most probably carried on.

    However other question is - are you sure that this issue shows on only one subsite and on other subsites it works as should? Because if other subsites are good - then Snapshot can be good option to move sites. But with that one where it is not working - I would try other way (https://premium.wpmudev.org/blog/moving-wordpress-site-into-multisite/ - it's single to MultiSite, but it should be possible to do the same with subsite to subsite).

    A second question is: If I want to import the users for my sub-sites, how do I do that using Snapshot?

    If you will import whole snapshot from one subsite to another it will also carry users.
    If you take a look on the section of tables when doing snapshot of the blog it says:

    These global user tables contain blog specific user information which can be included as part of the snapshot archive. Only users whose primary blog matches this selected blog will be included. Superadmin users will not be included in the sub-site archive.

    So even only doing backup of those tables you can move users from one subsite to another.

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.