Jump to content
Wanze

ProcessGoogleAnalytics

Recommended Posts

That's because the results were getting cached. But you still don't see any Statistics, right?

I think there has to be an error in your setup somewhere. Tested also the date "d-m-Y", works fine here on my local installation.

Will check if Google reports back some error codes in case something went wrong with the query params...

Edit:

If you want to do some more testing, you should disable caching the output:

1) Delete the folders starting with "ga_" in site/assets/cache/MarkupCache

2) In the Module Options, set Cache Time to "0"

Maybe i got the problem. I'm displaying the statistic of a new website...so no rows have been created, that's why i can see the notices and warning...but meanwhile i made some visitors and now i can see statistics except the mobile block that is still displaying those notices...

You have to manage this case. ;)

Share this post


Link to post
Share on other sites

If I had to wish for anything it would only be that I could get more detail on the referrers. Like when I see a new referrer show up, I'd love to click to see the URL where the referring link actually exists.

I remember seeing this somewhere, should be possible to implement with the GA api. Will be there in the next version :)

I'm not sure what the best behavior would be here, as I'm guessing everyone has their own workflow and timeline they want to look at in GA. But I do know that the first thing I do when I get into GA is to set a date range. It's rare that I want to look at the last month or year. Usually I want the last 24 hours, last 2 days, last week, etc. I've often wished that GA had a select box where I could choose "last 24 hours" for instance, rather than having to select starting and ending dates.

I think another module option to define the default date range makes sense. Currently, this is always a month back from "today". I will add a dropdown one can choose the the date range (24 hours, 2 days, 3 days... 1 week, 2 weeks etc.)

Maybe i got the problem. I'm displaying the statistic of a new website...so no rows have been created, that's why i can see the notices and warning...but meanwhile i made some visitors and now i can see statistics except the mobile block that is still displaying those notices...

You have to manage this case. ;)

Thank you for testing, glad it turned out to be this simple! ;-)

Will add the check in the next version. One quick fix for you is to visit the site with your mobile phone :grin:

  • Like 1

Share this post


Link to post
Share on other sites

Just commited version 1.1.1

  • Fixed PHP notices when debug mode is enabled (thanks Sevarf2!)
  • If no results are returned from GA, display "no results found"
  • Added module config option for a default date range: last 24 hours, last 2 days, last 3 days etc. If you want to look back more than 2 months by default, tell me... i'll add more values :)
  • Traffic Sources: Added Referral Sources by URL. Provides also a link to visit the referral page, but as Ryan mentioned earlier, sometimes uri-variables are stripped resulting in invalid links!

When you set a custom date range in the options section, you are "overwriting" the default date range. This can still be handy, for example if you want to look quickly at statistics from the past. Reset the custom date range to display stats again from the default one.

  • Like 3

Share this post


Link to post
Share on other sites

Awesome update, thanks Wanze!

Share this post


Link to post
Share on other sites

I'm getting a strange error when I go to the GA page (after authenticating) that shows up for each section were data is supposed to show up. The end of the errors say:

Values must match the following regular expression: 'ga:[0-9]+'"}

It is referencing the Google Analytics Account ID that I provided, which is in the format of UA-XXXXXXXX-X. That's the right GA Account ID to provide, correct?

The installation instructions say to "Choose a Google Analytics Account from the Dropdown". However, I didn't see any place to do that. Is that related to the problem I'm having?

Share this post


Link to post
Share on other sites

@hani you have to enter it in this format ga:xxxxxxx as mentioned before by wanze, though still not sure what numbers.

When I try ga:5735834-7 it doesn't work (regex not matching), when I enter ga:5735834, it seems to recognize it but still an error that access is not configured is shown. I also never come to select any account as mentioned in the description.

@wanze, I'm trying since hours to get this module working and no luck so far.

I got the same problem with entering the account id as mentioned above. After reading your posts again I still can't see what would be wrong. I entered all key and secrets and the account id, but it always returns some 400,403, or 500 or whatever.

The get is shown like this: "Error calling GET https:\/\/www.googleapis.com\/analytics\/v3\/data\/ga?ids=ga%3A5735834&start-date=2012-08-09&end-date=2012-09-09&metrics=ga..." (403) Access Not Configured"

So I wanted to uninstall the module, and I've seen that it will also uninstall the MarkupCache module in PW, which is a bad thing. It may be required by the module but a simple $modules->get will load it if installing you module, no need to make it required and uninstall it when uninstalling your module.

Share this post


Link to post
Share on other sites

Finally I seem to have it working after 1000 try and error. I create a new project on google API page, the one I already had was from another test I did a while ago. After entering the new key's I got still an error saying I don't have the permission... I'm not sure what I have done that it works now, but after authenticate, I can select an account after redirect.

OMG! But after selecting an account I again get the same error "(403) Access Not Configured"}". Can it be really that hard?

Share this post


Link to post
Share on other sites

Guys,

Sorry for the problems, let's find out why it isn't working.

The correct ID you must provide is really hard to find out and the docs from Google suck! If you can't see the dropdown to select an GA-Account, then we need to debug together because I just tested and it works on my installation.

Please try this:

Enter the ID manually and check if the module works.

You can find the ID in the Browsers URL when you are watching the statistics inside the normal Google Analytics page.

The ID is build with the numbers after the "p":

post-582-0-43538800-1347191796_thumb.png

Add these numbers in the module settings (Google Analytics Account Id) and add "ga:" in front -> Format: ga:xxxxxxx

Does it work?

Normally, the module should do this step for you by detecting all your accounts and then display the dropdown:

post-582-0-81537000-1347191968_thumb.png

Share this post


Link to post
Share on other sites

After a long time trying the account id I enter was always right. Though suddenly I've come to the select dropdown, but after selecting one I see again the error as before. Metioned in my previous post.

Share this post


Link to post
Share on other sites

After a long time trying the account id I enter was always right. Though suddenly I've come to the select dropdown, but after selecting one I see again the error as before. Metioned in my previous post.

Can you delete all the cache files startin with "ga_" in "site/assets/cache/MarkupCache/"

Just to make sure that the 403 errors are not cached!

If this doesn't work, I have to look in the docs from Google in which cases this error is returned...

Think I need to do some more error checking in the whole module...

Share this post


Link to post
Share on other sites

Please try this:

Enter the ID manually and check if the module works.

You can find the ID in the Browsers URL when you are watching the statistics inside the normal Google Analytics page.

The ID is build with the numbers after the "p":

post-582-0-43538800-1347191796_thumb.png

Add these numbers in the module settings (Google Analytics Account Id) and add "ga:" in front -> Format: ga:xxxxxxx

- Well is it meant to NOT enter the account ID in the module settings?

- When I don't enter a account ID the analytics page in PW throws error without continuing. When I enter any, I get to auth via google and after redirect back to PW there's not select at all (only once it was there) and the 403 is shown in each panel.

- The ID after the "p" is always different to every sub account.

- What ID really is supposed to go there?

Does it work?

- NO matter what ID I take it doesn't work.

- I always get a "403 access not configured"

Normally, the module should do this step for you by detecting all your accounts and then display the dropdown:

post-582-0-81537000-1347191968_thumb.png

- I don't have any

- I cleared cache any time I tried something.

And please take out the MarkupCache dependencies. Not sure you've read my first post from today completely. It shouldn't install or uninstall MarkupCache core module at all. If your module is using it no need to install it, as the first $modules->get("MarkupCache") ... will install it on demand. ;)

Share this post


Link to post
Share on other sites
@hani you have to enter it in this format ga:xxxxxxx as mentioned before by wanze

Oops! Totally missed that. Thanks. :)

But, like Soma, after I put that number in like Wanze instructed I'm getting the "403 access not configured" error. I've never seen the drop down.

Wanze, thanks for all your efforts on this module! I'll play around to see if I can figure out the solution.

Share this post


Link to post
Share on other sites

By the way - I figured out a straightforward way to get your Google Analytics Profile ID.

  1. Go to your Google Analytics Account and select the domain you're working with.
  2. Click on Admin near the top right
  3. Click on the Profile tab
  4. The number is located next to "Profile ID"

Like Soma mentioned, this is different for each domain you have in Google Analytics.

Share this post


Link to post
Share on other sites

- Well is it meant to NOT enter the account ID in the module settings?

And please take out the MarkupCache dependencies. Not sure you've read my first post from today completely. It shouldn't install or uninstall MarkupCache core module at all. If your module is using it no need to install it, as the first $modules->get("MarkupCache") ... will install it on demand. ;)

No it's not. After authenticating with Oauth, the Module should give you a Dropdown to choose your Analytics Account (Domain!). It grabs the ID and stores it.

If you delete the ID in the modules setting, you should be able to choose an Account from the dropdown again.

Thank you for your tip, i will remove the dependency for MarkupCache, didn't know that it will be installed by Pw!

By the way - I figured out a straightforward way to get your Google Analytics Profile ID.

  1. Go to your Google Analytics Account and select the domain you're working with.
  2. Click on Admin near the top right
  3. Click on the Profile tab
  4. The number is located next to "Profile ID"

Like Soma mentioned, this is different for each domain you have in Google Analytics.

Thanks. But if the module would work correctly, it would set this Id for you after you have chosen the GA-Account from the dropdown. No need to find it out by yourself!

Please note that you can only display statistics from one Domain.

There's definitely something going wrong :(

Tomorrow: I'll grab a fresh copy of Pw, create a new Google API's Project and finally install the module. Hope I can reproduce what's not working...

Share this post


Link to post
Share on other sites

Oh! Okay - I didn't know that you're supposed to leave the Profile ID blank and allow the module to set it for you once you select a domain from the drop down.

So, I revoked access, deleted the cached folders and re-authenticated. When I expected to see the drop down, I now see this error:

Error calling GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties?key=AIzaSyCrlnK06s5YWsui7VWnH62GFYjBqjAGpZw: (403) Access Not Configured

Share this post


Link to post
Share on other sites

I figured it out! :)

I noticed the AJAX queries to grab the data are including the API Developer key in the URL. However, according to Google (https://developers.g...rence#q_summary) it says that the parameter is optional and that you should do that when authenticating with OAuth 1.0. Since the module uses OAuth 2.0 for authentication, that query parameter should be left out.

I commented out this line in the module (line 930 under the _loadGoogleApi function):

$this->ga_client->setDeveloperKey($this->developerKey);

That seems to have done the trick! It's loading the data beautifully! (And it also allows me to select the domain in the drop down correctly too.)

  • Like 2

Share this post


Link to post
Share on other sites

I figured it out! :)

Yeah that's great thank you for finding this one! :)

Seems like Google does not accept this parameter anymore, worked fine some weeks ago... I will update the source on Github today.

Share this post


Link to post
Share on other sites

Thanks Hani for finding the issue. It works here too when changing.

Share this post


Link to post
Share on other sites

My pleasure! Thanks for this module, Wanze. I love it!

Share this post


Link to post
Share on other sites

Finally comitted the fix to Git!

I hope to make some other improvements in the next few weeks.

By the way, I found a stupid mistake. You were not supposed to see the "Google Analytics Account Id" in the module config, unless already chosen from the Dropdown. It's clear that people get confused when this setting exists right after the install...

Check this code out:

//Ga Account ID - only display when Account was chosen with dropdown before
$field = ($data['accountId']) ? $modules->get("InputfieldText") : $modules->get("InputfieldHidden");
$field = $modules->get("InputfieldText");

Aaaaaaaaaaargh >:( :-

  • Like 1

Share this post


Link to post
Share on other sites

One thing I noticed is that it can take quite some time to load the statistics and I think there should be some ajax loader indicator animation while it's loading.

  • Like 1

Share this post


Link to post
Share on other sites

Just wanted to say a huge thanks for the time you've put into this Wanze!

One tiny thing, can you tell me which line of code you set the admin heading. Just wanted to change from Google Analytics to Analytics to save some space in the menu!

I'm in awe of just how much code has gone into this, thanks again :)

Share this post


Link to post
Share on other sites

Thanks onjegolders, you're welcome! :)

You can change the title field of the GA-Page which is in your Site-Tree under "Admin".

Actually i hope to implement some planned improvements over the next week.

Share this post


Link to post
Share on other sites

Thanks onjegolders, you're welcome! :)

You can change the title field of the GA-Page which is in your Site-Tree under "Admin".

Actually i hope to implement some planned improvements over the next week.

Thanks Wanze, you know I didn't even realise I could access admin pages from the tree?! Cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...