[Follow our blog posts, obsession with data, and original articles on Twitter @RJMetrics]

With the recent public release, we’re excitedly working on an easy interface that will allow our customers to view their Google Analytics data from their RJMetrics business intelligence dashboards. Jake’s been having a fun time putting this together, and today we tag-teamed a bizarre bug that we thought we’d share.

As a quick background, anyone who wants to pull data from Google applications (contacts, calendar, web statistics, etc) needs to first be granted permission to do so by the user who owns or has legitimate access to that data. Google originally built its own “Google Authentication Service” to accomplish this, and has also recently adopted the open API authorization protocol OAuth.

Using the Google Authentication Service is very easy– in fact, a simple script like the one found can be uploaded to test it out without any modification. In essence, here’s what happens:

  • As a webmaster who wants to use a visitor’s data, you build a custom link that sends your visitor to a special Google page for permission authorization. You also send a variable that tells them where to redirect the user if they say it’s OK.
  • The Google page recognizes the domain name of the redirect URL you sent and asks if the user is comfortable sharing his or her information with the website at that domain.
  • Assuming they say yes, the users is redirected to the URL you specified, along with a token that you can then use to request their data via the Google API.

Optionally, you can make the permission authorization page less scary-looking (fewer warnings, etc) by “registering” your website with Google. This is a simple that basically associates a given URL with a Google Account.

Simple, right? We followed Google’s instructions and built the Google authorization URL exactly to specifications. However, when it was followed (from any machine) we received the following error:

The page you have requested cannot be displayed. Another site was requesting access to your Google Account, but sent a malformed request. Please contact the site that you were trying to use when you received this message to inform them of the error. A detailed error message follows:

The site “http://rjmetrics.com” has not been registered.

So here’s the strange part: site registration is optional, so the fact that we weren’t registered shouldn’t have mattered. In fact, if we changed the “next” variable in our custom Google URL (that’s the variable specifying where to send the user after approval) to any other domain (even one that didn’t exist), the process worked fine and the user could “grant access” and be sent back to whatever URL we had chosen… as long as it wasn’t rjmetrics.com.

Just to recap, we had an error message saying our domain “has not been registered,” but evidence that you don’t need to register your domain with Google in order for the page that generated the error to work. And, we couldn’t replicate this error on any of the dozens of other non-RJMetrics domains we tried. What made our domain so special? One thought was that we have always used Google Apps for our e-mail, calendars, etc, so our domain is already well known to Google (and at some point in time our ownership of the domain had been verified in some way).

While the error message was quite intriguing and somewhat nonsensical, our best chance at an easy fix was quite obvious: register our domain with Google. When I got to the domain registration page, things looked extremely familiar. I had done this before– way back when we first set up Google Apps for our domain I completed the steps on this exact same page. The only difference now was that, after registration was verified, we were given an OAuth Consumer Key and Token to use with that domain.

And that did it. As soon as we registered our site, the error message disappeared and the authorization process worked flawlessly.

OK, so the story is anticlimactic, but what’s really interesting is the error message we saw and the fact that our domain seemed exclusively exposed to this issue.

So, here’s what we think happened: At some point in time back before OAuth was being used by Google and possibly when the Google APIs were still young, we went through a “domain verification” process in order to use Google Apps with our domain. This created some kind of record on Google’s servers associated with the ownership of our domain name. However, when Google started using that same verification process to register domains for API usage (and slightly modified it to include OAuth), our legacy record stuck around but different or missing data associated with it.

Fast forward to today. We built the custom Google authentication URL that included our domain name as the “next” variable. Google found a record associated with our domain saying that it was registered in some way (thus not generating the page for un-registered URLs). However, our registration didn’t contain all of the information associated with API-related registrations. Since we didn’t qualify in either category, the result was the bizarre “not registered” warning (now especially bizarre since we actually were registered in some way).

When we went through the registration page this time, whatever old record had existed was overwritten and everything was repaired.

Anyway, if you get this error the quick fix is to simply register your domain with Google. Yes, we could have said that in a few hundred fewer words (heck, we could have tweeted it). What we enjoyed, however, was speculating about the origins of this strange behavior. We hope you enjoyed it too!

  • Evan Greensmith

    Thanks for recording this. Our previously working Google docs integration suddenly wasn’t. Not sure what happened. Going through the site registration got it working again.

  • Anup

    I recently went through the same problem. And the way google handles it is really illogical. After verification, google gives the same warning, that it gave prior to verification !

  • Brent

    Thank you so much! This exact same issue was driving me crazy. Registering the domain solved the problem.

  • Dale Jacobs

    I am stuck with this error message, when I got to the register domain name for google apps, it wont work since I already used the domain name to create the google app account.
    I registered the domain name with google web master tools and still no go, any thoughts?

  • Robert J. Moore

    Dale, sorry but I haven’t run into that issue before. You might want to try posting to this forum for help: http://www.google.com/support/forum/p/apps-apis?hl=en

  • Renee

    Can anyone send me the link to register my google apps site? I am having the same problem even though my account has been set up for months.

  • Dima

    Would love an explanation of where to register the domain. B/c I’m already set up with google apps, google analytics, even google webmaster tools. So I not sure where else to register it.

    Edit: After some searching, I found the URL, registered the domain (again), and the authorization then worked. Thx.
    https://www.google.com/accounts/ManageDomains

  • Brock

    I’ve been struggling with this for way too long. This article is the closest I’ve been to resolution, but even adding the domains to Google (which makes no sense to me since I already use Google Apps) isn’t working. When I try to authenticate using Google Analyticator for WordPress, I’m still getting the same error.
    I’m at the end of my rope here….any other suggestions?

    Also, what does this mean: “Must be the prefix of the next parameter used in AuthSub.”????

  • Randy

    I just fixed my google analyticator with this tip. After following the link above to add my domain, and then then manage it (I believe I selected the second radio button to get through the authorize part) I was finally at the manage screen where you set the “Target URL path prefix”. This parameter should be “http://yourdomain.com/wp-admin” without the quotes using your domain name, obviously, assuming /wp-admin is the location of your WordPress install, and not in a subfolder. Save it, and try authenticating with analyticator again. At first i had accidentally used a capital “H” on http and it failed. Fixed that, and it worked for me. Hope others find it works for them.

  • Natalie

    REALLY, this wasn’t helpful at all. SIMPLE TERMS MAN. Can you please help with all of these unnecessary words!?

  • visionwindmedia

    I had this same problem with my site not being registered or authenticating, I got it working and made a tutorial on fixing Google Analyticator for WordPress Errors: This site has not been registered and Target URL path prefix hope it helps.

  • Roy Hampton

    @Randy
    Dude, you are the man! Thank you so much for you post. I was so frustrated with this issue until I tried your suggestion. Now everything works great for me. Thanks.

  • Anthony C. Maki

    +1 :)

  • Genewood

    Excellent, this fixed my problem. I encountered it while trying to use the Google Analyticator for wordpress ( http://wordpress.org/extend/plugins/google-analyticator/ ). I ended up having to set the “Target URL path prefix” to ( http://www.example.com/wp-admin/options-general.php?page=google-analyticator.php )

  • Mike Haydon

    Thanks so much for all these tips. Eventually got it working! In addition to what @genewood said, don’t forget to add www if appropriate. That screwed me up right at the end. Just go to the Google Analyticator page you are trying to authenticate from and copy that url. So glad that particular nightmare is over!

  • Pingback: MailChimp Analytics360: Can't Connect to Google Analytics | Ask Joanne, LLC | Internet Research, Advertising and Analysis